Update 0070.爬楼梯.md

This commit is contained in:
fw_qaq
2023-04-10 15:36:23 +08:00
committed by GitHub
parent abbcbe1ed0
commit 03f037afeb

View File

@ -454,19 +454,16 @@ public class Solution {
```rust
impl Solution {
pub fn climb_stairs(n: i32) -> i32 {
if n <= 2 {
if n <= 1 {
return n;
}
let mut a = 1;
let mut b = 2;
let mut f = 0;
for i in 2..n {
let (mut a, mut b, mut f) = (1, 1, 0);
for _ in 2..=n {
f = a + b;
a = b;
b = f;
}
return f;
}
f
}
```