Skip to content

Commit 3ea4c37

Browse files
committed
feat: Upload climbing-stairs(typescript)
1 parent 38c6add commit 3ea4c37

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

climbing-stairs/mike2ox.ts

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

0 commit comments

Comments
 (0)