55. Jump Game

来源:互联网 发布:mac软件 编辑:程序博客网 时间:2024/06/05 17:40
class Solution(object):
    def canJump(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        
        m = 0
        for i, n in enumerate(nums):
            if i > m:
                return False
            m = max(m, i+n)

        return True


https://discuss.leetcode.com/topic/16704/1-6-lines-o-n-time-o-1-space

原创粉丝点击