New Self New Life
No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
New Self New Life
No Result
View All Result
Home Softwares

Find the longest Substring of a given String S

by admin
2 years ago
in Softwares
Best Coding Practices For Rest API Design
Share on FacebookShare on Twitter


import java.io.*;

import java.util.*;

  

public class GFG {

  

    

    

    public static void maxLength(int lis[], int n)

    {

        lengthy or = 0;

  

        

        

        for (int i = 0; i < n; i++) = lis[i];

        

  

        int[] rely = new int[32];

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < 32; j++) {

                if ((lis[i] & (1L << j)) != 0)

                    rely[j]++;

            }

        }

  

        lengthy ans = 0, l = 0, tempOr = 0;

        for (int r = 0; r < n; r++) {

            tempOr |= lis[r];

  

            boolean flag = true;

            for (int i = 0; i < 32; i++) {

                if ((lis[r] & (1L << i)) != 0) {

                    rely[i]--;

                    if (rely[i] == 0)

                        flag = false;

                }

            }

  

            

            if (!flag) {

                for (; l <= r;) {

                    boolean flag1 = true;

                    for (int i = 0; i < 32; i++) {

                        if ((lis[(int)l] & (1L << i))

                            != 0) {

                            rely[i]++;

                        }

                        if (rely[i] == 0)

                            flag1 = false;

                    }

                    l++;

                    if (flag1)

                        break;

                }

            }

  

            

            

            if (tempOr == or) {

  

                ans = Math.max(ans, r - l + 1);

            }

        }

  

        

        if (ans != 0)

            System.out.println(ans);

        else

            System.out.println(-1);

    }

  

    

    public static void important(String[] args)

    {

        String S = "2347";

        int N = S.size();

        int[] A = new int[N];

        for (int i = 0; i < N; i++) {

            A[i] = S.charAt(i) - '0';

        }

  

        

        maxLength(A, N);

    }

}



Source link

Tags: FindLongestStringSubstring
Previous Post

3AC founders seek US$25M for new venture GTX to fill FTX void

Next Post

Which is right for you?

Related Posts

AI updates from the past week: IBM watsonx Orchestrate updates, web search in Anthropic API, and more — May 9, 2025
Softwares

AI updates from the past week: IBM watsonx Orchestrate updates, web search in Anthropic API, and more — May 9, 2025

by admin
May 11, 2025
Unlocking the Future of Finance
Softwares

Unlocking the Future of Finance

by admin
May 8, 2025
Address bar tweaks – Vivaldi Browser snapshot 3683.4
Softwares

Address bar tweaks – Vivaldi Browser snapshot 3683.4

by admin
May 7, 2025
A faster, sleeker JavaScript experience
Softwares

A faster, sleeker JavaScript experience

by admin
May 10, 2025
How WordPress Agencies Can Improve Site Building Efficiency — Speckyboy
Softwares

How WordPress Agencies Can Improve Site Building Efficiency — Speckyboy

by admin
May 6, 2025
Next Post
Which is right for you?

Which is right for you?

Dolly Parton Confirms Paul McCartney, Stevie Nicks as LP Guests

Dolly Parton Confirms Paul McCartney, Stevie Nicks as LP Guests

  • Trending
  • Comments
  • Latest
Cameron Monaghan Discusses Erotic Thriller

Cameron Monaghan Discusses Erotic Thriller

January 13, 2022
Doctor Strange: 12 Best Comic Issues Of The 1990s

Doctor Strange: 12 Best Comic Issues Of The 1990s

December 11, 2021
Phantom Parade Gets Opening Movie, Cast Announced

Phantom Parade Gets Opening Movie, Cast Announced

March 8, 2022
Anant Ambani wedding: Celebs, wealthy elite attend lavish billionaire festivities – National

Anant Ambani wedding: Celebs, wealthy elite attend lavish billionaire festivities – National

March 1, 2024
The Best Crime Shows on Netflix

The Best Crime Shows on Netflix

May 27, 2023
POORSTACY “Knife Party” video featuring Oli Sykes

POORSTACY “Knife Party” video featuring Oli Sykes

January 27, 2022
I Tried Calocurb For 90 Days. Here’s My Review.

I Tried Calocurb For 90 Days. Here’s My Review.

January 8, 2025
Guide for Odoo Website Razorpay Checkout Payment Acquirer

Guide for Odoo Website Razorpay Checkout Payment Acquirer

January 6, 2023
I’m Frustrated With How Many New Characters Played A Critical Role At The End Of This Episode

I’m Frustrated With How Many New Characters Played A Critical Role At The End Of This Episode

May 11, 2025
RuPaul’s Drag Race’s DeJa Skye ‘Almost Died’ After Weight Loss Surgery

RuPaul’s Drag Race’s DeJa Skye ‘Almost Died’ After Weight Loss Surgery

May 11, 2025
Teen Mom's Loudest Enemies Call A Truce! Inside Jenelle Evans & Farrah Abraham's Dinner Date!

Teen Mom's Loudest Enemies Call A Truce! Inside Jenelle Evans & Farrah Abraham's Dinner Date!

May 11, 2025
Vivo Y300 GT Unveiled: 144Hz Display, Dimensity 8400, And a 7620mAh Battery

Vivo Y300 GT Unveiled: 144Hz Display, Dimensity 8400, And a 7620mAh Battery

May 11, 2025
Study Uncovers the One Thing That Cuts Through Climate Apathy: Loss

Study Uncovers the One Thing That Cuts Through Climate Apathy: Loss

May 10, 2025
Millennium Docs Against Gravity Expands Industry Program

Millennium Docs Against Gravity Expands Industry Program

May 10, 2025
Billy Ray Cyrus shares rare photo with daughter Miley amid rumoured family rift

Billy Ray Cyrus shares rare photo with daughter Miley amid rumoured family rift

May 10, 2025
Galantis Is Throwing a Midsommar-Themed Concert at Red Rocks

Galantis Is Throwing a Midsommar-Themed Concert at Red Rocks

May 10, 2025
New Self New Life

Your source for entertainment news, celebrities, celebrity news, and Music, Cinema, Digital Lifestyle and Social Media and More !

Categories

  • Celebrity
  • Cinema
  • Devices
  • Digital Lifestyle
  • Entertainment
  • Music
  • Social Media
  • Softwares
  • Uncategorized

Recent Posts

  • I’m Frustrated With How Many New Characters Played A Critical Role At The End Of This Episode
  • RuPaul’s Drag Race’s DeJa Skye ‘Almost Died’ After Weight Loss Surgery
  • Teen Mom's Loudest Enemies Call A Truce! Inside Jenelle Evans & Farrah Abraham's Dinner Date!
  • Home
  • Disclaimer
  • DMCA
  • Privacy Policy
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites. slotsfree  creator solana token

No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices

Copyright © 2021 New Self New Life.
New Self New Life is not responsible for the content of external sites.

lodi777