Accpeted simple Python DP solution.


  • 21
    X
    class Solution:
        # @return an integer
        def uniquePaths(self, m, n):
            aux = [[1 for x in range(n)] for x in range(m)]
            for i in range(1, m):
                for j in range(1, n):
                    aux[i][j] = aux[i][j-1]+aux[i-1][j]
            return aux[-1][-1]

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.