We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://leetcode.cn/problems/climbing-stairs/solution/pa-lou-ti-by-leetcode-solution/
时间复杂度 O(n) 空间复杂度O(n)
var climbStairs = function(n) { const cache = {} const fn = (n) => { if(n === 1) return 1 if(n === 2) return 2 if(cache[n]) return cache[n] const res = fn(n-1) + fn(n-2) cache[n] = res return res } return fn }();
时间复杂度 O(n) 空间复杂度O(1)
var climbStairs = function(n) { let a = 0 let b = 0 let c = 1 for(let i =0;i <n; i++ ){ b = a a = c c = a + b } return c };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
https://leetcode.cn/problems/climbing-stairs/solution/pa-lou-ti-by-leetcode-solution/
缓存递归
时间复杂度 O(n)
空间复杂度O(n)
动态规划(滚动数组)
时间复杂度 O(n)
空间复杂度O(1)
动态规划
The text was updated successfully, but these errors were encountered: