class Solution {
public:
int uniquePaths(int m, int n) {
if (m == 0 || n == 0) {
return 1;
}
std::vector<std::vector<int>> dp(m, std::vector<int>(n));
dp[0][0] = 1;
for (int c = 1; c < n; ++c) {
dp[0][c] = 1;
}
for (int r = 1; r < m; ++r) {
dp[r][0] = 1;
}
for (int r = 1; r < m; ++r) {
for (int c = 1; c < n; ++c) {
dp[r][c] = dp[r - 1][c] + dp[r][c - 1];
}
}
return dp[m - 1][n - 1];
}
};
——————————————————————————————————