Skip to main content

Jump Game

Question

None

Example 1
Input: nums = [3,2,1,0,4]
Output: false (Not able to jump to the last index)

Solution

all//Jump Game.py


def canJump(nums):
last_pos = len(nums) - 1
for i in range(last_pos, -1, -1):
if i + nums[i] >= last_pos:
last_pos = i
return last_pos == 0