判断一个物体从左上角到右下角有多少种走法
1 class Solution(object): 2 def uniquePaths(self, m, n): 3 flag = [[1 for j in range(n)] for i in range(m)] 4 for i in range(1,m): 5 for j in range(1,n): 6 flag[i][j] = flag[i-1][j] + flag[i][j-1] 7 return flag[-1][-1]
判断一个物体从左上角到右下角有多少种走法
1 class Solution(object): 2 def uniquePaths(self, m, n): 3 flag = [[1 for j in range(n)] for i in range(m)] 4 for i in range(1,m): 5 for j in range(1,n): 6 flag[i][j] = flag[i-1][j] + flag[i][j-1] 7 return flag[-1][-1]