You are given a 0-indexed array of integers nums. Each element represents your maximum jump length at that position.
Return the minimum number of jumps needed to reach the last index. You can assume the last index is always reachable.
Examples
Input: nums = [2,3,1,1,4] Output: 2
Input: nums = [2,3,0,1,4] Output: 2
Constraints
- 1 <= nums.length <= 10,000
- 0 <= nums[i] <= 1,000
- The last index is reachable.