File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 1
1
2
2
3
+
3
4
// tag renovizee 2week
4
5
// https://github.com/DaleStudy/leetcode-study/issues/230
5
6
// https://leetcode.com/problems/climbing-stairs/ #70 #Easy
6
7
class Solution {
7
- // Solv1 :
8
+ // Solv1
8
9
// 시간복잡도 : O(n)
9
10
// 공간복잡도 : O(n)
10
11
public int climbStairs (int n ) {
12
+ int [] dp = new int []{1 , 2 };
13
+
14
+ if (n == dp [0 ]) {
15
+ return dp [0 ];
16
+ }
17
+
18
+ if (n == dp [1 ]) {
19
+ return dp [1 ];
20
+ }
21
+
22
+ for (int i = 3 ; i <= n ; i ++) {
23
+ int nextWayCount = dp [0 ] + dp [1 ];
24
+ dp [0 ] = dp [1 ];
25
+ dp [1 ] = nextWayCount ;
26
+ }
27
+
28
+ return dp [1 ];
11
29
12
30
}
13
31
}
14
32
//-------------------------------------------------------------------------------------------------------------
15
33
// Java 문법 피드백
16
- //
34
+ // 1) Math.pow(2, 3) 2의 3승.
17
35
//-------------------------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments