Skip to content

Instantly share code, notes, and snippets.

@smlee729
Created April 1, 2018 16:38
Show Gist options
  • Save smlee729/f056d0854b0be053f26e17583862a3bf to your computer and use it in GitHub Desktop.
Save smlee729/f056d0854b0be053f26e17583862a3bf to your computer and use it in GitHub Desktop.
Jump Game
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