Skip to content

Jump Game

MediumGreedy
Decode it first. Clues, constraints, pattern and plan before any code.

You stand on index 0 of nums. From index i you may jump forward up to nums[i] places. Return true if you can reach the last index.

nums = [2, 3, 1, 1, 4]  →  true    (0 → 1 → 4)
nums = [3, 2, 1, 0, 4]  →  false   (every route lands on the 0 at index 3)
nums = [0]              →  true    (you start at the end)

Constraints

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