思路:顺序遍历数组,并时刻与最后的位置比较
class Solution:
# @param A, a list of integers
# @return a boolean
def canJump(self, A):
n=len(A)
if(n==0 or n==1):
return True
else:
max_step=A[0]
for i in range(1,n):
if(max_step==0):
return False
max_step=max_step-1
max_step=max(max_step,A[i])
if(i+max_step>=n-1):
return True