/55. Jump Game

55. Jump Game

Medium
Arrays40.6% acceptance

Given an integer array jump_limits, where jump_limits[i] represents the maximum number of indices you can move forward from index i, determine if it is possible to reach the last index starting from the first index. Return True if possible, otherwise return False.

Example 1

Input: [1,2,0,1,3]

Output: True

Explanation: You can jump from index 0 to 1, then from 1 to 3, then from 3 to 4.

Example 2

Input: [4,0,0,0,0]

Output: True

Explanation: You can jump directly from index 0 to index 4.

Example 3

Input: [0,1,2,3]

Output: False

Explanation: You cannot move from index 0 as jump_limits[0] is 0.

Constraints

  • 1 <= len(jump_limits) <= 104
  • 0 <= jump_limits[i] <= 105 for all valid i
Python (current runtime)

Case 1

Input: [2,1,2,0,1]

Expected: True

Case 2

Input: [1,0,1,0]

Expected: False

Case 3

Input: [5,0,0,0,0,0]

Expected: True

Case 4

Input: [1,1,1,1,0]

Expected: True

Case 5

Input: [0]

Expected: True