Skip to content

Commit af4f23c

Browse files
committed
solve 70
1 parent 24e71a5 commit af4f23c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

climbing-stairs/mumunuu.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// 70. Climbing Stairs https://leetcode.com/problems/climbing-stairs/description/
2+
class Solution {
3+
public int climbStairs(int n) {
4+
5+
6+
if (n <= 2) {
7+
return n;
8+
}
9+
10+
int a = 1;
11+
int b = 2;
12+
13+
for (int i = 3; i <= n; i++) {
14+
int temp = b;
15+
b = a + b;
16+
a = temp;
17+
}
18+
19+
return b;
20+
21+
22+
}
23+
}

0 commit comments

Comments
 (0)