Skip to content
New issue

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

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

Already on GitHub? # to your account

爬楼梯 #426

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

爬楼梯 #426

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} n
 * @return {number}
 */
var climbStairs = function(n) {
    if(n <= 2) return n;
    let dp = [];
    dp[1] = 1;
    dp[2] = 2;
    for(let i = 3; i <= n; i++){
        let sum = dp[1] + dp[2];
        dp[1] = dp[2];
        dp[2] = sum;
    }
    return dp[2]
};

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

No branches or pull requests

2 participants