Greedy Algorithms
Medium

Jump Game

Determine if you can reach the last index.
Problem Understanding

You are given an array nums. nums[i] is the maximum jump length from that position. Return true if you can reach the last index.

Strategy

We can track the maximum reachable index.

  1. Init reachable = 0.
  2. Iterate i from 0 to nums.length - 1.
  3. If i > reachable, we are stuck! Return false.
  4. Update reachable = max(reachable, i + nums[i]).
  5. If reachable >= last_index, return true.
Interactive Visualization
Step 1 / 1

Initializing...

1x
See the Logic in Motion
Stop memorizing code. Unlock the full interactive visualizer to master the logic step-by-step.
Unlock VisualizerPREMIUM FEATURE

Stop Guessing, Start Mastering.

Build the FAANG intuition. Master this pattern with optimized implementations, visual dry runs, and our curated collection of high-yield problems.

Start Your Premium Prep