Skip to content

Commit

Permalink
Merge pull request youngyangyang04#2105 from fwqaaq/patch-27
Browse files Browse the repository at this point in the history
Update 0070.爬楼梯完全背包版本.md about rust
  • Loading branch information
youngyangyang04 authored Jun 8, 2023
2 parents cf8e53a + 824ce31 commit f83bbd4
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 f83bbd4

Please sign in to comment.