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 be0e435 commit 9036bb9Copy full SHA for 9036bb9
climbing-stairs/nakjun12.ts
@@ -0,0 +1,10 @@
1
+// T.C: O(n)
2
+// S.C: O(n)
3
+
4
+function climbStairs(n: number) {
5
+ const dp = { 1: 1, 2: 2 };
6
+ for (let i = 3; i <= n; i++) {
7
+ dp[i] = dp[i - 1] + dp[i - 2];
8
+ }
9
+ return dp[n];
10
+}
0 commit comments