FunctionRacerProblemsRace

Current Streak

HardNumPyPython

wins holds 0s and 1s. Return an array where item i is the length of the run of 1s that ends at i, or 0 when wins[i] is 0. No loops: for and while are not allowed.

Example 1

wins [1,1,0,1,1,1]
returns [1,2,0,1,2,3]

The run that ends at index 1 has two 1s. The 0 at index 2 starts the count again.

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 NumPy problems