程式語言 - LeetCode - C - 62. Unique Paths



參考資訊:
https://algo.monster/liteproblems/62
https://www.cnblogs.com/grandyang/p/4353555.html

題目:


解答:

int uniquePaths(int m, int n)
{
    int i = 0;
    int j = 0;
    int r[100][100] = { 0 };
 
    r[0][0] = 1;
    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
            if (i > 0) {
                r[i][j] += r[i - 1][j];
            }

            if (j > 0) {
                r[i][j] += r[i][j - 1];
            }
        }
    }
 
    return r[m - 1][n - 1];
}