Problems > Longest Block of Ones

Longest Block of Ones

Difficulty: 900 2000 ms 128 MB

strings

In a binary string, find the length of the longest block of consecutive 1s.

Input: one line with a binary string.

Output: the longest run of 1s (0 if there are none).

Constraints:

  • 1 ≤ |S| ≤ 105

Sample Tests

Input 1
110111
Output 1
3
Input 2
000
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.