Skip to content

Commit 543a879

Browse files
committed
climbing stairs solved
1 parent 60d1865 commit 543a879

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

climbing-stairs/sora0319.java

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

0 commit comments

Comments
 (0)