Sliding Window (Python 3)


#1
class Solution:
# @param A : list of integers
# @return an integer
def canJump(self, a):
    ans=['F']*len(a)
    n=len(a)
    if n==1:return 1
    for i in range(n-1,-1,-1):
        if i+a[i]>=n:ans[i]='T'
        else:
            k=i+1
            while k<=i+a[i]:
                if ans[k]=='T':
                    ans[i]='T'
                k+=1
    if ans[0]=='T':return 1
    return 0