Loading...
Loading...
Loading...
A list of marks is given in the order the students handed in. Find the length of the longest block of consecutive students with exactly the same mark.
Example
Input
8 5 5 7 7 7 5 5 5
Output
3
The blocks have lengths 2, 3 and 3. The longest is 3.
Try the problem first. Open one hint at a time.
Walk through the marks once and keep the length of the current block.
When the mark changes, restart the block at 1. Update the best length at every step.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor