diff --git a/problems/0070.爬楼梯.md b/problems/0070.爬楼梯.md index c46e3b46..793d3e67 100644 --- a/problems/0070.爬楼梯.md +++ b/problems/0070.爬楼梯.md @@ -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 } ```