Problem
You get an array of non-negative integers nums. You start at index 0. The value nums[i] is the longest jump that you can make from index i.
From index i, you can move to any index from i + 1 to i + nums[i]. Return the smallest number of jumps that you need to reach the last index.
The input always lets you reach the last index.
Example 1
- Input:
- nums = [1,4,1,1,1,2]
- Output:
- 2
- Explanation:
- Jump 1 step from index 0 to index 1. Then jump 4 steps from index 1 to index 5, which is the last index.
Example 2
- Input:
- nums = [3,1,1,1]
- Output:
- 1
- Explanation:
- One jump of 3 steps moves you from index 0 to the last index.
Constraints
- 1 <= nums.length <= 10^4
- 0 <= nums[i] <= 1000
- You can always reach the last index.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Jump Game
Coding · Array · Dynamic Programming · Greedy
- Best Time to Buy and Sell Stock II
Coding · Array · Dynamic Programming · Greedy
- Minimum Number of Refueling Stops
Coding · Array · Dynamic Programming · Greedy
- Non-overlapping Intervals
Coding · Array · Dynamic Programming · Greedy
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Amazon
Leetcode 45. Jump Game II
Reported Sep 17, 2026 · 2 source reports
JUNIOR, SENIOR
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 2 records
Flipkart
Jump Game II
Reported date not specified · Source window: 6mo
Source snapshot: Oct 20, 2026
Source frequency score: 55.4. This is not an interview probability.
View sourceSalesforce
Jump Game II
Reported date not specified · Source window: 6mo
Source snapshot: Oct 20, 2026
Source frequency score: 55.3. This is not an interview probability.
View source