Handle Score
@Ibrahim Nash 6381
@blackshadows 6329
@mb1973 5388
@Quandray 5231
@akhayrutdinov 5111
@saiujwal13083 4510
@sanjay05 3762
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3357
@KshamaGupta 3318
Complete Leaderboard
Max Length Removal
Easy Accuracy: 63.65% Submissions: 38 Points: 2

Given a binary string (consists of only 0 and 1). If there is “100” as a sub-string in the string, then we can delete this sub-string. The task is to find the length of longest sub-string which can be make removed?

Example 1:

Input  : 
str = "1011100000100"
Output :
Explanation :
Sub-strings present in str that can be make
removed 101{110000}0{100}. First
sub-string 110000-->100-->null, length is = 6.
Second sub-string 100-->null, length is = 3


Example 2:

Input  :
str = "111011"
Output :
Explanation :
There is no sub-string which can be make null.


Your Task:  
You don't need to read input or print anything. Your task is to complete the function longestNull() which takes the string S[] as inputs and returns the length of the longest string that can be removed.


Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

1 ≤ string length ≤ 104
S[i] = {0, 1}

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Max Length Removal

Output Window