Skip to content

Commit b4d25ab

Browse files
committed
feat: week02 climbing-stairs
1 parent 8702661 commit b4d25ab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

climbing-stairs/std-freejia.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int climbStairs(int n) {
3+
int[] dp = new int [n + 1];
4+
5+
if (n == 1) return 1;
6+
dp[1] = 1;
7+
dp[2] = 2;
8+
9+
for (int i = 3; i <= n; i++) {
10+
dp[i] = dp[i - 1] + dp[i - 2];
11+
}
12+
return dp[n];
13+
}
14+
}

0 commit comments

Comments
 (0)