Skip to content

Commit bf02135

Browse files
committed
feat: climbing-stairs
1 parent 24570a3 commit bf02135

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

climbing-stairs/choidabom.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// https://leetcode.com/problems/climbing-stairs/
2+
3+
// TC: O(N)
4+
// SC: O(N)
5+
6+
var climbStairs = function (n) {
7+
const stairs = [1, 2];
8+
9+
for (let i = 2; i < n; i++) {
10+
stairs[i] = stairs[i - 1] + stairs[i - 2];
11+
}
12+
13+
return stairs[n - 1];
14+
};
15+
16+
console.log(climbStairs(5));

0 commit comments

Comments
 (0)