Skip to content

Commit dda1a7d

Browse files
committed
Add climbin-stairs solution - s0ooo0k
1 parent cc29e97 commit dda1a7d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

climbing-stairs/s0ooo0k.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
/*
3+
* 시간복잡도 O(n)
4+
* 공간복잡도 O(n)
5+
*/
6+
public int climbStairs(int n) {
7+
int[] piv = new int[n+1];
8+
piv[0]=1;
9+
piv[1]=2;
10+
11+
for(int i=2; i<n; i++) {
12+
piv[i]=piv[i-1]+piv[i-2];
13+
}
14+
return piv[n-1];
15+
}
16+
}

0 commit comments

Comments
 (0)