Skip to content

Commit ce93354

Browse files
committed
climbing stairs solution
1 parent 972ba03 commit ce93354

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

climbing-stairs/RiaOh.js

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

0 commit comments

Comments
 (0)