LeetCode 55 Jump Game - Implementation

The approach

Track max reachable position.

def canJump(nums): farthest = 0

for i in range(len(nums)):
    if i > farthest:
        return False
    farthest = max(farthest, i + nums[i])

return True

O(n)O(n) time, O(1)O(1) space.