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

How to Add Custom Style Variations to WordPress Blocks — Speckyboy
Softwares

How to Add Custom Style Variations to WordPress Blocks — Speckyboy

by admin
June 2, 2025
Smart software replaces expensive sensors for glass wall detection with 96% accuracy
Softwares

Smart software replaces expensive sensors for glass wall detection with 96% accuracy

by admin
June 1, 2025
User Guide For UnoPim PDF Generator
Softwares

User Guide For UnoPim PDF Generator

by admin
May 31, 2025
Infragistics Ultimate 25.1 includes updates across several of its UI toolkit components
Softwares

Infragistics Ultimate 25.1 includes updates across several of its UI toolkit components

by admin
May 29, 2025
Quick exit from Settings – Vivaldi Android Browser snapshot 3708.4
Softwares

Quick exit from Settings – Vivaldi Android Browser snapshot 3708.4

by admin
June 3, 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
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
Product Information Management Trends (PIM)

Product Information Management Trends (PIM)

February 4, 2022
How to Build a JavaScript Search [Article]

How to Build a JavaScript Search [Article]

August 30, 2022
15 Best Movies Like Parasite

15 Best Movies Like Parasite

February 20, 2022
Every Kathryn Hahn Film Performance, Ranked

Every Kathryn Hahn Film Performance, Ranked

December 24, 2022
What is Kubernetes: An Overview

An Introduction to Kubernetes | Developer.com

August 11, 2022
How to Build a DIY Spotify Music Player with Raspberry Pi Pico

How to Build a DIY Spotify Music Player with Raspberry Pi Pico

May 13, 2025
Deployment Diagrams Explained in Detail, With Examples

Deployment Diagrams Explained in Detail, With Examples

August 11, 2021
‘Midas Man’ Producer Kevin Proctor Pleads Not Guilty To Stalking

‘Midas Man’ Producer Kevin Proctor Pleads Not Guilty To Stalking

June 4, 2025
When Karate Kid: Legends Takes Place In The Timeline

When Karate Kid: Legends Takes Place In The Timeline

June 4, 2025
Teddi Mellencamp Confirms New Romance Amid Cancer Battle

Teddi Mellencamp Confirms New Romance Amid Cancer Battle

June 4, 2025
Major Labels Shift Gears, Explore Licensing Deals With Controversial AI Platforms Suno and Udio

Major Labels Shift Gears, Explore Licensing Deals With Controversial AI Platforms Suno and Udio

June 3, 2025
Samsung Galaxy Z Fold 7 Rumored Features and Design Updates

Samsung Galaxy Z Fold 7 Rumored Features and Design Updates

June 3, 2025
Ellen Pompeo Detained By TSA, Bomb Squad Called In

Ellen Pompeo Detained By TSA, Bomb Squad Called In

June 3, 2025
X Rolls Out Support for 4K Video Uploads

X Continues To Highlight Misleading Claims About Its Popularity

June 3, 2025
May 30-June 1 Box Office Recap – ‘Lilo & Stitch’ crosses $600M worldwide, while ‘Mission: Impossible – The Final Reckoning’ crosses $350M worldwide. ‘Karate Kid: Legends’ and ‘Bring Her Back’ have solid debuts, while ‘The Phoenician Scheme’ opens with the best per-theater average ($93K) of the year.

May 30-June 1 Box Office Recap – ‘Lilo & Stitch’ crosses $600M worldwide, while ‘Mission: Impossible – The Final Reckoning’ crosses $350M worldwide. ‘Karate Kid: Legends’ and ‘Bring Her Back’ have solid debuts, while ‘The Phoenician Scheme’ opens with the best per-theater average ($93K) of the year.

June 3, 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

  • ‘Midas Man’ Producer Kevin Proctor Pleads Not Guilty To Stalking
  • When Karate Kid: Legends Takes Place In The Timeline
  • Teddi Mellencamp Confirms New Romance Amid Cancer Battle
  • 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.

New Self New Life