CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsArrays

Max Consecutive Ones

Easy
LeetCode
14/14
EasyArraysLeetCode #485

Max Consecutive Ones

Count streaks of 1s; keep a max.

Examples

Example 1

Input

6
1 1 0 1 1 1

Output

3
Example 2

Input

4
1 0 1 1

Output

2

Stuck? Take a nudge

C++17Autosaves