Skip to content

Commit

Permalink
Merge pull request #133 from KyrieChang/patch-3
Browse files Browse the repository at this point in the history
Update 0070.爬楼梯.md Java 版本
  • Loading branch information
youngyangyang04 authored May 15, 2021
2 parents ecc6781 + bd707f8 commit 78f2e76
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;
}
}
```

```java
// 常规方式
Expand Down

0 comments on commit 78f2e76

Please sign in to comment.