[leetcode]Unique Paths

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];

    }

};


你可能感兴趣的:(LeetCode)