We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent acf0c26 commit ab7ebdfCopy full SHA for ab7ebdf
1 file changed
climbing-stairs/hyejj19.ts
@@ -0,0 +1,13 @@
1
+function climbStairs(n: number, memo = {}): number {
2
+ // 재귀 종료조건
3
+ if (n === 1) return 1;
4
+ if (n === 2) return 2;
5
+
6
+ // 값이 메모에 존재하면 해당 값을 리턴
7
+ if (memo[n] !== undefined) return memo[n];
8
9
+ // 아니라면 계산 후 메모이징
10
+ memo[n] = climbStairs(n - 1, memo) + climbStairs(n - 2, memo);
11
12
+ return memo[n];
13
+}
0 commit comments