Friday, September 12, 2014

Leetcode: Jump Game @Python

class Solution:
    # @param A, a list of integers
    # @return a boolean
    def canJump(self, A):
        crt=-1
        for i in range(len(A)-1):
            crt=max(crt-1,A[i])
            if crt==0:
                return False
        return True

No comments :

Post a Comment