FunctionRacerProblemsRace

Max Consecutive Ones

BeginnerArraysPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Arrays problems