Skip to content

Practice Jump Game II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#45
LeetCode Problem

Jump Game II

Problem Statement

Start at index 0 of nums. From index i, one jump may move to i + j for any integer j from 0 through nums[i] while staying within the array. Return the minimum number of jumps needed to reach the final index. The input guarantees that the final index is reachable.

Source: Jump Game II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [2,3,1,1,4]
Output
2

# Example 2

Input
nums = [2,3,0,1,4]
Output
2

Constraints

1 <= nums.length <= 10^4
0 <= nums[i] <= 1000
It's guaranteed that you can reach nums[n - 1].

Related LeetCode Problems

Practice more problems similar to Jump Game II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.