Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f83bbd4

Browse files
Merge pull request youngyangyang04#2105 from fwqaaq/patch-27
Update 0070.爬楼梯完全背包版本.md about rust
2 parents cf8e53a + 824ce31 commit f83bbd4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎problems/0070.爬楼梯完全背包版本.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,25 @@ function climbStairs(n: number): number {
225225
};
226226
```
227227

228+
Rust:
228229

229-
230+
```rust
231+
impl Solution {
232+
pub fn climb_stairs(n: i32) -> i32 {
233+
let (n, m) = (n as usize, 2);
234+
let mut dp = vec![0; n + 1];
235+
dp[0] = 1;
236+
for i in 1..=n {
237+
for j in 1..=m {
238+
if i >= j {
239+
dp[i] += dp[i - j];
240+
}
241+
}
242+
}
243+
dp[n]
244+
}
245+
}
246+
```
230247

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /