Skip to main content

Jump Game

MediumGreedy

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

Example:

Input: nums = [2,3,1,1,4]
Output: true
Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.

Constraints:

  • 1 <= nums.length <= 10^4
  • 0 <= nums[i] <= 10^5