首页 > 其他 > 详细

LeetCode Unique Paths

时间:2017-03-07 11:34:08      阅读:170      评论:0      收藏:0      [点我收藏+]

//给定m*n的矩阵,从左上角走到左下角需要多少步?

class Solution {
public:
    int uniquePaths(int m, int n) {
        
        vector<vector<int> > table(m, vector<int>(n, 1));  
        for (int i = 1; i < m; i++)  
        {  
            for (int j = 1; j < n; j++)  
            {  
                table[i][j] = table[i-1][j] + table[i][j-1];  
            }  
        }  
        return table[m-1][n-1];  
    }
    
};

 

LeetCode Unique Paths

原文:http://www.cnblogs.com/xiuxiu55/p/6513831.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!