반응형
leetcode.com/problems/jump-game/
class Solution:
def canJump(self, nums: List[int]) -> bool:
n = len(nums)
i = 0
farthest = nums[0]
while i < n and i <= farthest :
farthest = max(farthest, i+nums[i])
i += 1
return farthest >= n-1
반응형
'0 > leetcode' 카테고리의 다른 글
416. Partition Equal Subset Sum (0) | 2020.09.18 |
---|---|
784. Letter Case Permutation (0) | 2020.09.10 |
207. Course Schedule (0) | 2020.09.08 |
41. First Missing Positive (0) | 2020.09.08 |
988. Smallest String Starting From Leaf (0) | 2020.09.08 |