Largest Substring
Practice
3.7 (25 votes)
Algorithms
Binary search
Easy
Hash maps
Implementation
Searching
String manipulation
Problem
72% Success 7055 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a string $$S$$ of length $$N$$. Each character of the string is either $$0$$ or $$1$$. Now, you need to select the largest substring in which the count of $$0$$ in the string is more than the count of $$1$$. Print the maximum possible length of the subarray in the output.

Input

The first line contains an integer $$N$$ as input. 
The next line contains a string comprising of $$0$$ and $$1$$. The length of this string is exactly $$N$$.

Output

In the output print the length of the largest substring in which the count of $$0$$ is more than $$1$$.

Constraints

$$1 \le N \le 10^5$$

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
23 votes
Tags:
AlgorithmsBinary SearchC++
Points:30
13 votes
Tags:
Graph TheoryApprovedMediumShortest path problem
Points:20
39 votes
Tags:
AlgorithmsApprovedBinary SearchEasyGrammar-VerifiedRecruitSearching