45. Jump Game II
Practice Jump Game II for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
You start at index 0 of nums. From index i you may move forward by any number of steps from 1 up to nums[i]. Return the smallest number of moves needed to land on the last index. The last index is always reachable.
Example
nums = [2,3,1,1,4] -> 2 (0 -> 1 -> 4)
nums = [2,3,0,1,4] -> 2
Constraints
- 1 <= nums.length <= 10^4
- 0 <= nums[i] <= 1000
- The last index can be reached