Created
June 12, 2021 02:14
-
-
Save jeb2239/a6602e23edff53946ed7e3e6afd787cd 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
class Solution: | |
def canJump(self, nums: List[int]) -> bool: | |
if len(nums)==1: | |
return True | |
minjump=1 | |
idx=len(nums)-2 | |
while idx >= 0: | |
if nums[idx]>=minjump: | |
minjump=1 | |
else: | |
minjump+=1 | |
idx-=1 | |
if minjump > 1: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment