Greedy Algorithms
Medium
Jump Game
Determine if you can reach the last index.
10 min read
Solve on LeetCodeProblem 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.
- Init
reachable = 0. - Iterate
ifrom 0 tonums.length - 1. - If
i > reachable, we are stuck! Returnfalse. - Update
reachable = max(reachable, i + nums[i]). - If
reachable >= last_index, returntrue.
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.ON THIS PAGE
- Problem Understanding
- Strategy
- Interactive Visualization
- Edge Cases & Common Mistakes
- Complexity Analysis
- Solution
- Complexity Analysis
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.
