Skip to content

Commit 1110f1e

Browse files
committed
feat: [easy] climbing-stairs 문제 풀이
1 parent 97ce36d commit 1110f1e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

climbing-stairs/hyoeun-kim.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const cache: number[] = [];
2+
3+
function climbStairs(n: number): number {
4+
if(n === 1) return 1
5+
if(n === 2) return 2;
6+
7+
// cache 값 있을 때
8+
if(cache[n]) return cache[n]
9+
10+
// cache 값 없을 때
11+
cache[n] = climbStairs(n - 1) + climbStairs(n - 2);
12+
return cache[n]
13+
};

0 commit comments

Comments
 (0)