61. Max Consecutive Ones
EasyArray
The array contains only 0s and 1s. Print the length of the longest run of consecutive 1s.
Input format
Line 1: n Line 2: n values (0 or 1)
Output format
The longest run length.
Example 1
Input
6 1 1 0 1 1 1
Output
3
Example 2
Input
3 0 0 0
Output
0
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…