noodleProblems/
Jump Game
#63

Jump Game

AlgorithmmediumArrayDynamic ProgrammingGreedy

You are given an integer array nums. You start at the first index, and each element nums[i] is the **maximum** number of steps you can jump forward from that position.

Return true if you can reach the last index, and false otherwise.

Example cases

  • reachable
    in nums = [2,3,1,1,4]
    out true
    Jump 1 step to index 1, then 3 steps to the last index.
  • stuck at zero
    in nums = [3,2,1,0,4]
    out false
    You always land on index 3, whose value 0 lets you go no further.
  • single
    in nums = [0]
    out true
    Already at the last index.

Constraints

  • 1 <= nums.length <= 10^4
  • 0 <= nums[i] <= 10^5
Saved
nums =
[2,3,1,1,4]