Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2022 23:18
What would you like to do?
def jump_game(nums):
:type nums: List[int]
:rtype: bool
if len(nums) == 0:
return False
if len(nums) == 1:
return True
curr_max_reach = 0
for i in range(len(nums)):
if i > curr_max_reach:
return False
curr_max_reach = max(curr_max_reach, i + nums[i])
if curr_max_reach >= len(nums) - 1:
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment