My python codes


  • 0
    A
    def canJump(self, nums):
        length = len(nums)
        curMaxDes = 0
        for i in range(length):
            if curMaxDes >= i:
                curMaxDes = max(i+nums[i], curMaxDes)
            else:
                break
        if curMaxDes >= length-1:
            return True
        else:
            return False
                
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.