Skip to content

Commit 366f453

Browse files
committed
climbing-stairs solution
1 parent 881f158 commit 366f453

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

climbing-stairs/chjung99.java

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

0 commit comments

Comments
 (0)