Intermediate
Open
Pro
Jump to the End
You are given a 0-indexed array of non-negative integers nums.
You start at index 0. nums[i] is the maximum number of steps
you are allowed to jump forward from index i (you may jump any
number of steps from 1 up to nums[i], or fewer).
Return true if you can reach the last index of the array, or
false otherwise.
Example 1
Input: nums = [2, 3, 1, 1, 4]
Output: true
Explanation: Jump 1 step from index 0 to index 1, then 3 steps to
the last index (index 4).
Example 2
Input: nums = [3, 2, 1, 0, 4]
Output: false
Explanation: No matter how you jump, you always land on index 3,
whose max jump length is 0, so index 4 is never reachable.
Constraints
1 <= nums.length <= 10^40 <= nums[i] <= 10^5
Share this question