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

User Guide For Recipe App For Wix
Softwares

User Guide For Recipe App For Wix

by admin
May 13, 2025
Software update keeps Newark airport radar online but network concerns and flight limits remain
Softwares

Software update keeps Newark airport radar online but network concerns and flight limits remain

by admin
May 14, 2025
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
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
Best Cryptocurrency Wallets Comparison | SCAND Blog

Best Cryptocurrency Wallets Comparison | SCAND Blog

July 30, 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 Data Lake Security Checklist: IT Leader Essentials

The Data Lake Security Checklist: IT Leader Essentials

August 1, 2022
Adobe commerce module seller invitation

Adobe commerce module seller invitation

April 13, 2022
Advancement in predicting software vulnerabilities

Advancement in predicting software vulnerabilities

May 21, 2022
The Best Crime Shows on Netflix

The Best Crime Shows on Netflix

May 27, 2023
IMS Dubai Scheduled to Return in November 2025

IMS Dubai Scheduled to Return in November 2025

May 14, 2025
Coolife Luggage Set review – A compelling case – or three

Coolife Luggage Set review – A compelling case – or three

May 14, 2025
SNL’s Sarah Sherman Breaks Silence On Aimee Lou Wood Skit

SNL’s Sarah Sherman Breaks Silence On Aimee Lou Wood Skit

May 14, 2025
Pinterest Outlines How to Optimize Your Marketing Approach

Pinterest Outlines How to Optimize Your Marketing Approach

May 14, 2025
Menendez brothers: L.A. judge to decide if Erik and Lyle should be freed – National

Menendez brothers: L.A. judge to decide if Erik and Lyle should be freed – National

May 14, 2025
Burger King Sued for Making Whopper Look Bigger on TV

Burger King Sued for Making Whopper Look Bigger on TV

May 14, 2025
La Dispute to return with new album No One Was Driving The Car and tour

La Dispute to return with new album No One Was Driving The Car and tour

May 13, 2025
User Guide For Recipe App For Wix

User Guide For Recipe App For Wix

May 13, 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

  • IMS Dubai Scheduled to Return in November 2025
  • Coolife Luggage Set review – A compelling case – or three
  • SNL’s Sarah Sherman Breaks Silence On Aimee Lou Wood Skit
  • 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.

online slot meter