Jump Game
Given a 0-indexed array nums where each nums[i] is the maximum jump length from index i, determine whether you can reach the last index starting from index 0. Return true if reachable, otherwise false.
Open official problem prompt ↗Decide whether a chain of forward jumps can carry you from the first cell all the way to the last.
Like refueling a car where each cell's value is how much gas it grants: as long as you never coast to a stop before the next station, you keep pushing your maximum range forward until it covers the finish line.
- Input
- nums = [2, 3, 1, 1, 4]
- Output
- true
- Why
- Jump 1 step to index 1, then 3 steps to the last index.
1 <= nums.length <= 10^40 <= nums[i] <= 10^5