dsa · medium
Jump Game II (Min Jumps)
GreyOrangeArrayGreedy
nums[i] is max jump length from i. Return the minimum jumps to reach the last index. You can always reach it.
Arguments
nums— the input array of integers
**Example:** [2,3,1,1,4] → 2.
Constraints
1 <= nums.length <= 1000 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [2,3,1,1,4] Expected: 2
Example 2
Input: [2,3,0,1,4] Expected: 2