Skip to content

Instantly share code, notes, and snippets.

@paramsingh
Created January 6, 2022 23:18
Show Gist options
  • Save paramsingh/4b40b50867af55dab81a5df8c7677af2 to your computer and use it in GitHub Desktop.
Save paramsingh/4b40b50867af55dab81a5df8c7677af2 to your computer and use it in GitHub Desktop.
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