A higher resolution is required to access the IDE
- 17
Statement
Goal
A binary substring is balanced if the number ofGiven a binary string S, find the maximum number of consecutive balanced substrings. The substring must not be overlapping (e.g. 010 contains one balanced substring either 01 or 10). Also, the binary substring must not be empty.
Example:
For example if S=
Another example is: for S =
Input
Line 1: N An integer denoting the number of characters in S.
Line 2: A binary string S.
Line 2: A binary string S.
Output
The maximum number of consecutive balanced substrings in S.
Constraints
1<=N<=3000
Example
Input
10 0010110101
Output
4
A higher resolution is required to access the IDE