62. Unique Paths

class Solution(object):
    def uniquePaths(self, m, n):
        """
        :type m: int
        :type n: int
        :rtype: int
        """
        
        d=[[0 for i in range(n)] for j in range(m)]
        for i in range(0,n):
            d[0][i]=1
        for j in range(0,m):
            d[j][0]=1
        for i in range(1,m):
            for j in range(1,n):
                d[i][j]=d[i-1][j]+d[i][j-1]
        return d[m-1][n-1]

你可能感兴趣的:(62. Unique Paths)