LeetCode20. 有效的括号
题目链接
https://leetcode.cn/problems/jump-game/
代码
python
class Solution:
def canJump(self, nums: List[int]) -> bool:
if len(nums) <= 1:
return True
cover = 0
for i in range(len(nums)):
if i <= cover:
cover = max(cover, i + nums[i])
if cover >= len(nums) - 1:
return True
return False