Question: https://oj.leetcode.com/problems/jump-game/
Question Name: Jump Game
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | class Solution: # @param A, a list of integers # @return a boolean def canJump(self, A): # Initially we can only access the first position reachable = [False] * len(A) reachable[0] = True for index in xrange(len(A)): # Not reachable to current position if reachable[index] == False: break for step in xrange(A[index], 0, -1): # Out of range if index+step >= len(A): continue # Already reached if reachable[index+step] == True: break reachable[index+step] = True return reachable[-1] |