Max Consecutive Ones
nums holds only 0s and 1s. Return the length of the longest unbroken run of 1s. If there are no 1s, return 0.
Example 1
nums [1,1,0,1,1,1]
returns 3
The last run has three 1s.
Constraints
1 <= len(nums) <= 100- Each item is 0 or 1.
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Arrays problems
- Peak So FarBeginner
- Running Sum of an ArrayBeginner
- Second AppearanceBeginner
- Shift Right and FillBeginner
- Shuffle the ArrayBeginner
- Sort by ParityBeginner
- Trend SignsBeginner
- Alternate the SignsEasy