class Solution {
public:
    /**
     * 
     * @param m int整型 
     * @param n int整型 
     * @return int整型
     */
    /*
    dp(m,n) = dp (m-1,n) + dp(m, n-1)
    if (i == 0 || j == 0) {
        dp = 1;
    }
    */
    int uniquePaths(int m, int n) {
        if (m == 0 || n == 0 || m == 1 || n == 1) {
            return 1;
        }
        vector<vector<int>> dp (m + 1, vector<int>(n + 1, 0));
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= n; j++) {
                if (i == 0 || j == 0) {
                    dp[i][j] = 0;
                } else if (i == 1 || j == 1) {
                    dp[i][j] = 1;
                } else {
                    dp[i][j] = dp[i-1][j] + dp[i][j-1];
                }
            }
        }
        return dp[m][n];
        // write code here
    }
};