您的位置:首页 > 其它

LeetCode-55-Jump Game 贪心水题

2017-09-19 21:21 567 查看
class Solution(object):
def canJump(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
Len=len(nums)
if Len<=1:return True
reach=0
for i in range(Len):
if i<=reach:
reach=max(reach,i+nums[i])
else:
return False
return True
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: