LeetCode-55-Jump Game 贪心水题

来源:互联网 发布:fifa online3新数据库 编辑:程序博客网 时间:2024/05/16 12:25


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        


原创粉丝点击