Skip to content

Commit

Permalink
Update 0070.爬楼梯.md
Browse files Browse the repository at this point in the history
添加 0070.爬楼梯 Java版本
  • Loading branch information
KyrieChang authored May 15, 2021
1 parent db78516 commit bd707f8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions problems/0070.爬楼梯.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ public:
Java:
```Java
class Solution {
public int climbStairs(int n) {
// 跟斐波那契数列一样
if(n <= 2) return n;
int a = 1, b = 2, sum = 0;
for(int i = 3; i <= n; i++){
sum = a + b;
a = b;
b = sum;
}
return b;
}
}
```


Python:
Expand Down

0 comments on commit bd707f8

Please sign in to comment.