Loading...
Loading...
Loading...
You stand on the first cell. Cell i holds the longest jump you may make from it. The last cell can always be reached. Print the smallest number of jumps needed to land on the last cell.
Example 1
Input
2 3 1 1 4
Output
2
Example 2
Input
2 3 0 1 4
Output
2
Try the problem first. Open one hint at a time.
Think in levels: the cells reachable with one jump, then two jumps.
When the index reaches the end of the current level, count a jump and move the level end to the farthest reach.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor