Skip to content

Instantly share code, notes, and snippets.

@paramsingh
Created January 6, 2022 23:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
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