LintCode:跳跃游戏
贪心:
class Solution:
# @param A, a list of integers
# @return a boolean
def canJump(self, A):
# write your code here
if not A or len(A) == 1:
return True
n = len(A) - 1
i = n - 1
while i >= -1:
if A[i] + i >= n:
if i == 0:
return True
n = i
i -= 1
else:
i -= 1
return False
动态规划:
这里写代码片