Jump Game

Determine if you can reach the last index.

Pattern

Greedy Reach

This problem follows the Greedy Reach pattern, commonly found in the Greedy category. Recognizing this pattern is key to solving it efficiently in an interview setting.

Approach

How to Solve It

Track the farthest reachable index. If current index exceeds it, return false.

Key Insight

You don't need to simulate jumps — just track the farthest reachable position. If you ever land beyond it, you're stuck.

Step-by-step

  1. 1Track the farthest index you can reach
  2. 2Iterate through each index
  3. 3If the current index > farthest, you're stuck — return false
  4. 4Update farthest = max(farthest, i + nums[i])
  5. 5If farthest >= last index, return true

Pseudocode

farthest = 0
for i in range(len(nums)):
    if i > farthest: return false
    farthest = max(farthest, i + nums[i])
return true
Complexity Analysis

Time Complexity

O(n)

Space Complexity

O(1)
More Greedy Problems

Master this pattern with YeetCode

Practice Jump Game and similar Greedy problems with flashcards. Build pattern recognition through active recall.

Practice this problem