首页 > 程序开发 > 软件开发 > C++ >

[leetcode]Unique Paths

2013-07-27

class Solution {public: int uniquePaths(int m, int n) { // Start typing your C/C++ solution below // DO NOT write int main() function ...

class Solution {
public:
    int uniquePaths(int m, int n) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        vector<vector<int>> f(m, vector<int>(n, 1));
        
        for(int i = 1; i < m; i++){
            for(int j = 1; j < n; j++){
                f[i][j] = f[i-1][j] + f[i][j-1];
            }
        }
        return f[m-1][n-1];
    }
};

相关文章
最新文章
热点推荐