Redirecting to
NADOS

Maximum Difference Of Zeros And Ones In Binary String

1. You are given a string containing only 0's and 1's.
2. You have to find the length of substring which is having maximum difference of number of 0s and number of 1s i.e (Number of 0's - Number of 1's).
3. If there are all 1's present in the given string, then print '-1'.
Input Format
A Binary String
Output Format
A number 
Question Video
Constraints
1 <= length of string <= 10^5
Sample Input
11000010001
Sample Output
6


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name