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 11
22
3+
34// tag renovizee 2week
45// https://github.com/DaleStudy/leetcode-study/issues/230
56// https://leetcode.com/problems/climbing-stairs/ #70 #Easy
67class Solution {
7- // Solv1 :
8+ // Solv1
89 // 시간복잡도 : O(n)
910 // 공간복잡도 : O(n)
1011 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 ];
1129
1230 }
1331}
1432//-------------------------------------------------------------------------------------------------------------
1533// Java 문법 피드백
16- //
34+ // 1) Math.pow(2, 3) 2의 3승.
1735//-------------------------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments