Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int uniquePaths(int m, int n)
- {
- if (!m || !n)
- return 0;
- vector<vector<int> > dp(m, vector<int>(n, 1));
- for (int i = 1; i < m; ++i)
- {
- for (int j = 0; j < n; ++j)
- {
- dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
- }
- }
- return dp[m - 1][n - 1];
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement