Jump Game
Part of Practice: Reach & Reset
You start at index 0 of an integer array nums. Each value nums[i] is the maximum number of steps you may jump forward from index i — you can always choose a shorter jump. Return true if you can reach the last index, and false if you inevitably get stuck.
Constraints that matter: up to 10,000 elements and values from 0 to 100,000. A zero is the only thing that can trap you, but only if you cannot jump over it from somewhere earlier.
Examples
- Input:
- nums = [2, 3, 1, 1, 4]
- Output:
- true
Jump 1 step from index 0 to index 1, then 3 steps to the last index.
- Input:
- nums = [3, 2, 1, 0, 4]
- Output:
- false
Every path funnels into index 3, which has jump length 0, and no earlier index can jump past it.
- Input:
- nums = [0]
- Output:
- true
You start on the last index, so no jump is needed.
Hints
One at a time — struggle first, peek second.
Your thinking space — verify on LeetCode, then mark it.