Jump Game II
Starting at index zero, nums[i] is your maximum forward jump length from i. Return the fewest jumps needed to reach the final index.
Example 1
nums = [2,3,1,1,4]2Explanation
Jump 0->1->4; two jumps suffice and one does not.
Example 2
nums = [1,1,1]2Explanation
One-step limits require two jumps to reach index 2.
Example 3
nums = [0]0Explanation
Start already equals finish, requiring no jumps.
Constraints
- 1 <= len(nums) <= 10000
- Values are 0..1000
- The final index is reachable
Function contract
jumpArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
[2,3,1,1,4]