#C10588. Longest Non-Defective Subsequence
Longest Non-Defective Subsequence
Longest Non-Defective Subsequence
You are given a binary string S
of widgets, where a '0' represents a non-defective widget and a '1' represents a defective one. Your task is to find the length of the longest contiguous subsequence of non-defective widgets in the string.
Mathematically, if we define a subsequence length as L, you are to compute:
$$L=\max_{subsequence}\{\text{length}\; (\text{consecutive } 0's)\}\ $$For example, if S = "110001110"
, the longest contiguous subsequence of '0's is of length 3.
inputFormat
The input consists of a single line containing a binary string S
(only characters '0' and '1').
outputFormat
Output a single integer representing the length of the longest contiguous subsequence of non-defective widgets (i.e. consecutive '0's) in the string.
## sample110001110
3