Python simple and short DP


#1
import collections
class Solution:
    # @param A : list of list of integers
    # @return an integer
    def uniquePathsWithObstacles(self, A):
        if len(A) < 1 or len(A[0]) < 1:
            return 0
        D = collections.defaultdict(int)
        D[(-1, 0)] = 1
        for y in range(len(A)):
            for x in range(len(A[0])):
                if A[y][x] == 1:
                    continue
                D[(y,x)] = D[(y-1,x)] + D[(y,x-1)]
        return D[(len(A)-1,len(A[0])-1)]