-
-
Save smlee729/f056d0854b0be053f26e17583862a3bf to your computer and use it in GitHub Desktop.
Jump Game
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 canJump(self, nums): | |
""" | |
:type nums: List[int] | |
:rtype: bool | |
""" | |
if len(nums) == 1: | |
return True | |
left_most_good_index = None | |
for i in xrange(len(nums)-2, -1, -1): | |
if nums[i] + i >= len(nums)-1: | |
left_most_good_index = i | |
if left_most_good_index and nums[i] + i >= left_most_good_index: | |
left_most_good_index = i | |
return left_most_good_index == 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment