Skip to interview prep
Apexed
Problem list102 / 125

102. Minimum Jumps to the End

MediumGreedy

You start at index 0 of nums; from index i you may jump forward up to nums[i] positions. Return the minimum number of jumps needed to reach the last index. The last index is always reachable.

Example 1

Input: nums = [2, 3, 1, 1, 4]
Output: 2
Explanation: Jump to index 1, then to the end.

Constraints

  • 1 ≤ nums.length ≤ 10⁴
  • 0 ≤ nums[i] ≤ 1000

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 5 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Minimum Jumps to the End — coding interview practice — Apexed