Runs of Equal Values
A run is a stretch of equal neighbors in values. Return the runs in order as [value, length] pairs. No loops: for and while are not allowed.
Example 1
values [5,5,2,2,2,5]
returns [[5,2],[2,3],[5,1]]
5 comes back at the end, and that is a new run of its own.
Constraints
1 <= len(values) <= 100-9 <= values[i] <= 9
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Two Closest PointsHard
- Vote of the NearestHard
- Above Average CountBeginner
- Average TemperatureBeginner
- Black and WhiteBeginner
- Celsius to FahrenheitBeginner
- Clip ScoresBeginner
- CorrelationBeginner