Back to Practice
#0282
Jump Game
MediumDSA28 min20 XP
Problem
Given nums where nums[i] is the maximum jump length from i, return True if you can reach the last index.
Why This Matters
Jump Game is the classic greedy reachability problem: keep the farthest reachable index.
Function Signature
def can_jump(nums):
Examples
Example 1
Inputnums = [2,3,1,1,4]
OutputTrue
Jump from index 0 to 1, then from 1 to the end.
Constraints
- Return the exact requested value.
- Handle edge cases cleanly.
- Use the intended DSA pattern when brute force would scale poorly.
CodePython
Visible browser tests run here when available.
Testcases2 visible / 3 hidden categories
Reachable
Input[2,3,1,1,4]
ExpectedTrue
The reachable frontier keeps moving forward.
Stuck at zero
Input[3,2,1,0,4]
ExpectedFalse
Index 4 is beyond the farthest reachable index.
Hidden Test Categories
single elementzero at startlarge early jump