LC 55 — Problem

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise.

Input: nums = 23114
Output: true
Jump 1 step from index 0 to 1, then 3 steps to the last index.
Input: nums = 32104
Output: false
You always arrive at index 3 where nums[3] = 0. No way past it.

Constraints: 1 ≤ nums.length ≤ 10⁴ · 0 ≤ nums[i] ≤ 10⁵

What does it mean for a position to be “reachable”? Your first instinct might be to try every possible path — start at index 0, pick a jump, land somewhere, pick another jump. If ANY sequence of jumps gets you to the end, the answer is true.

That sounds manageable. After all, arrays are just numbered boxes — how hard can it be to hop across a handful of them? Let's find out. Each value below is your maximum jump length at that position. Tap the stones to jump from index 0 to the last index.

nums = [2, 3, 1, 1, 4]
2
0
3
1
1
2
1
3
4
4