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 be4fb1c commit 1636c6fCopy full SHA for 1636c6f
climbing-stairs/hyer0705.ts
@@ -0,0 +1,11 @@
1
+function climbStairs(n: number): number {
2
+ const dp: number[] = Array.from({ length: n + 1 }, () => 0);
3
+ dp[0] = 1;
4
+ dp[1] = 1;
5
+
6
+ for (let i = 2; i < n + 1; i++) {
7
+ dp[i] = dp[i - 1] + dp[i - 2];
8
+ }
9
10
+ return dp[n];
11
+}
0 commit comments