← Back to DSA Animator
Jump Game LC #55 Medium Greedy · Max Reach
Problem

You are given an integer array nums. You start at index 0, and each element represents your maximum jump length from that position. Return true if you can reach the last index, or false otherwise.

Example 1
Input: nums = [2,3,1,1,4]
Output: true
Explanation: Jump 1 from index 0→1, then 3 steps to the end.
Example 2
Input: nums = [3,2,1,0,4]
Output: false
Explanation: Always stuck at index 3 (nums[3]=0, can't move forward).
Constraints: 1 ≤ nums.length ≤ 10⁴  |  0 ≤ nums[i] ≤ 10⁵
Try Examples
Custom:
Approach
Greedy — Track the Farthest Reachable Index
Scan left→right: at each index, extend maxReach. If you ever stand beyond maxReach, you're permanently stuck — return false.
Jump Arena
Variables
Index i
nums[i]
i + nums[i]
maxReach
0
Step Logic
Press ▶ Play or Next Step to begin the animation.
🎉
Ready
0 / 0
Select an example above and press Play.
Algorithm
1
Init maxReach = 0 (furthest index reachable so far)
2
If i > maxReach: index unreachable → return false
3
Update maxReach = max(maxReach, i + nums[i])
4
Processed all indices without getting stuck → return true
Time
O(n)
Space
O(1)
Why Greedy Works

We never need to track exact jump paths. All we care about is the farthest index reachable from any position visited so far. If index i is within that range, we can reach it — and from it, potentially push the frontier further. The moment i exceeds our frontier, no combination of earlier jumps can save us.