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

[pull] master from youngyangyang04:master #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 6 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion problems/0070.爬楼梯完全背包版本.md
View file Open in desktop
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
13 changes: 7 additions & 6 deletions problems/0377.组合总和IV.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,17 @@ Rust
```Rust
impl Solution {
pub fn combination_sum4(nums: Vec<i32>, target: i32) -> i32 {
let mut dp = vec![0; target as usize + 1];
let target = target as usize;
let mut dp = vec![0; target + 1];
dp[0] = 1;
for i in 1..=target as usize {
for &j in nums.iter() {
if i as i32 >= j {
dp[i] += dp[i- j as usize];
for i in 1..=target {
for &n in &nums {
if i >= n as usize {
dp[i] += dp[i - n as usize];
}
}
}
return dp[target as usize];
dp[target]
}
}
```
Expand Down
19 changes: 10 additions & 9 deletions problems/0518.零钱兑换II.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,18 @@ func change(amount int, coins []int) int {

Rust:
```rust
pub fn change(amount: i32, coins: Vec<i32>) -> i32 {
let amount = amount as usize;
let coins = coins.iter().map(|&c|c as usize).collect::<Vec<usize>>();
let mut dp = vec![0usize; amount + 1];
dp[0] = 1;
for i in 0..coins.len() {
for j in coins[i]..=amount {
dp[j] += dp[j - coins[i]];
impl Solution {
pub fn change(amount: i32, coins: Vec<i32>) -> i32 {
let amount = amount as usize;
let mut dp = vec![0; amount + 1];
dp[0] = 1;
for coin in coins {
for j in coin as usize..=amount {
dp[j] += dp[j - coin as usize];
}
}
dp[amount]
}
dp[amount] as i32
}
```

Expand Down

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