Leetcode#62 Unique Paths

原题地址

 

基本动态规划题

 

代码:

 1 int uniquePaths(int m, int n) {
 2         vector<int> sum(n, 0);
 3         
 4         sum[n - 1] = 1;
 5         for (int i = m - 1; i >= 0; i--)
 6             for (int j = n - 2; j >= 0; j--)
 7                 sum[j] += sum[j + 1];
 8                 
 9         return sum[0];
10 }

 

posted @ 2015-01-27 18:24  李舜阳  阅读(157)  评论(0编辑  收藏  举报