Skip to content

Commit c0433e1

Browse files
committed
climbing-stairs solved
1 parent 0315108 commit c0433e1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

climbing-stairs/mintheon.java

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

0 commit comments

Comments
 (0)