v9.1.1
Menu

Jump Game

mediumFREEGreedyBlind 75

Given an array nums where each element represents the maximum jump length from that position, determine if you can reach the last index starting from index 0.

Example

Input
2,3,1,1,4
Output
True
Reasoning
  • We start at index 0 with a maximum jump length of 2, allowing us to reach indices 1 and 2.
  • From index 1, we have a maximum jump length of 3, enabling us to reach indices 2, 3, and 4.
  • Since we can reach index 4, which is the last index, we determine that it is possible to reach the end of the array.
  • The function returns True, indicating that we can successfully jump to the last index from index 0.

Constraints

  • 1 <= len(nums) <= 10^4
  • 0 <= nums[i] <= 10^5

Learn this in

More from Blind 75

solution.py

Test results

Sign in to run your code against the test cases.