Loading...
Loading...
Loading...
Stepping stones in a row each show the longest jump you can make from them. From stone i you may jump forward any number of stones from 1 up to its value. Starting on the first stone, print the fewest jumps to reach the last stone. The last stone can always be reached.
Example 1
Input
2 3 1 1 4
Output
2
Jump to the second stone, then straight to the end.
Example 2
Input
1 1 1
Output
2
Try the problem first. Open one hint at a time.
Think of levels: the stones you can reach with k jumps form a block.
Track the farthest stone reachable so far and the end of the current block.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor