题解 | #求路径#
求路径
http://www.nowcoder.com/practice/166eaff8439d4cd898e3ba933fbc6358
动态规划
# # # @param m int整型 # @param n int整型 # @return int整型 # class Solution: def uniquePaths(self , m , n ): # write code here dp = [[0 for _ in range(n)] for _ in range(m)] for i in range(0, m): dp[i][0] = 1 for j in range(0, n): dp[0][j] = 1 for i in range(1, m): for j in range(1, n): dp[i][j] = dp[i-1][j] + dp[i][j-1] return dp[m-1][n-1]