贪心算法
class Solution: def canJump(self, nums: List[int]) -> bool: n = len(nums) farthest = 0 i = 0 while i < n-1: farthest = max(farthest, i+nums[i]) if farthest <= i: return False i += 1 return farthest >= n-1
原文:https://www.cnblogs.com/zhaojiayu/p/14860910.html