Skip to content

Commit

Permalink
Update 0070.爬楼梯完全背包版本.md about rust
Browse files Browse the repository at this point in the history
  • Loading branch information
fwqaaq authored May 27, 2023
1 parent 5cbb991 commit 824ce31
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion problems/0070.爬楼梯完全背包版本.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,25 @@ function climbStairs(n: number): number {
};
```

Rust:


```rust
impl Solution {
pub fn climb_stairs(n: i32) -> i32 {
let (n, m) = (n as usize, 2);
let mut dp = vec![0; n + 1];
dp[0] = 1;
for i in 1..=n {
for j in 1..=m {
if i >= j {
dp[i] += dp[i - j];
}
}
}
dp[n]
}
}
```

<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
Expand Down

0 comments on commit 824ce31

Please sign in to comment.