[leetcode DP]62.Unique Paths

判断一个物体从左上角到右下角有多少种走法

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]

 

posted @ 2017-03-12 16:20  wilderness  阅读(108)  评论(0编辑  收藏  举报