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 #267

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 9 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
May 18, 2023
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit Hold shift + click to select a range
bd22ad9
Update 0343.ๆ•ดๆ•ฐๆ‹†ๅˆ†.md
fwqaaq Apr 13, 2023
14c25f2
Update ่ƒŒๅŒ…็†่ฎบๅŸบ็ก€01่ƒŒๅŒ…-1.md about rust
fwqaaq Apr 28, 2023
e6ad637
Update ่ƒŒๅŒ…็†่ฎบๅŸบ็ก€01่ƒŒๅŒ…-2.md about rust
fwqaaq Apr 28, 2023
d2650cc
Update problems/่ƒŒๅŒ…็†่ฎบๅŸบ็ก€01่ƒŒๅŒ…-2.md
fwqaaq Apr 28, 2023
18a16f9
Ignore .DS_Store files.
crazytan Apr 30, 2023
cff40cf
Merge pull request #2061 from fwqaaq/patch-39
youngyangyang04 May 18, 2023
2e519ac
Merge pull request #2062 from fwqaaq/patch-40
youngyangyang04 May 18, 2023
d37658d
Merge pull request #2068 from crazytan/master
youngyangyang04 May 18, 2023
3264d7a
Merge pull request #2031 from fwqaaq/patch-38
youngyangyang04 May 18, 2023
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
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,39 @@ object Solution {
}
```

### Rust

```rust
pub struct Solution;

impl Solution {
pub fn wei_bag_problem1(weight: Vec<usize>, value: Vec<usize>, bag_size: usize) -> usize {
let mut dp = vec![vec![0; bag_size + 1]; weight.len()];
for j in weight[0]..=weight.len() {
dp[0][j] = value[0];
}

for i in 1..weight.len() {
for j in 0..=bag_size {
match j < weight[i] {
true => dp[i][j] = dp[i - 1][j],
false => dp[i][j] = dp[i - 1][j].max(dp[i - 1][j - weight[i]] + value[i]),
}
}
}
dp[weight.len() - 1][bag_size]
}
}

#[test]
fn test_wei_bag_problem1() {
println!(
"{}",
Solution::wei_bag_problem1(vec![1, 3, 4], vec![15, 20, 30], 4)
);
}
```

<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/็ฝ‘็ซ™ๆ˜Ÿ็ƒๅฎฃไผ ๆตทๆŠฅ.jpg" width="1000"/>
Expand Down

AltStyle ใซใ‚ˆใฃใฆๅค‰ๆ›ใ•ใ‚ŒใŸใƒšใƒผใ‚ธ (->ใ‚ชใƒชใ‚ธใƒŠใƒซ) /