Jump Game II
Medium
LC #45
greedybfsarrayNot attempted yet
You start at index 0 of nums. From index i you may
jump forward up to nums[i] steps. The last index is
always reachable.
Return the minimum number of jumps to reach the last index.
Example 1
Input: nums = [2,3,1,1,4]
Output: 2
Jump to index 1, then 3 steps to the end.
Example 2
Input: nums = [2,3,0,1,4]
Output: 2
Example 3
Input: nums = [0]
Output: 0
Constraints
- 1 <= nums.length <= 10^5
- 0 <= nums[i] <= 1000
- The last index is reachable