CodeOath
← All problems

Jump Game

Medium
dynamic-programminggreedy

Given an integer array nums, you start at the first index. nums[i] is the maximum jump length from index i. 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