Skip to content

Commit d238880

Browse files
committed
climbing-stairs 문제 dp 풀이
- time complexity : O(n) - space complexity : O(1)
1 parent 1fc517a commit d238880

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

climbing-stairs/highball.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const climbStairs = function (n) {
2+
const dp = [1, 1];
3+
4+
for (let i = 0; i < n - 1; i++) {
5+
const temp = dp[1];
6+
dp[1] = temp + dp[0];
7+
dp[0] = temp;
8+
}
9+
10+
return dp[1];
11+
};

0 commit comments

Comments
 (0)