贪心算法
思路:
代码:
class Solution: def canJump(self, nums: List[int]) -> bool: n,maxindex = len(nums),0 for i in range(n): if i <= maxindex: maxindex = max(maxindex,i+nums[i]) if maxindex >= n-1: return True return False
原文:https://www.cnblogs.com/nilhxzcode/p/13042400.html