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