-
-
Save paramsingh/4b40b50867af55dab81a5df8c7677af2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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