Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不同路径 #424

Open
Pcjmy opened this issue Jan 26, 2023 · 1 comment
Open

不同路径 #424

Pcjmy opened this issue Jan 26, 2023 · 1 comment

Comments

@Pcjmy
Copy link
Contributor

Pcjmy commented Jan 26, 2023

No description provided.

@lxy-Jason
Copy link
Contributor

/**
 * @param {number} m
 * @param {number} n
 * @return {number}
 */
var uniquePaths = function(m, n) {
    let dp = new Array(m).fill(0).map(() => new Array(n).fill(0))
    for(let i = 0; i < m; i++){
        dp[i][0] = 1
    }
    for(let i = 0; i < n; i++){
        dp[0][i] = 1
    }
    for(let i = 1; i < m; i++){
        for(let j = 1; j < n; j++){
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
        }
    }
    return dp[m - 1][n - 1]
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants