Skip to content
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

fix: 背包理论011rust版本中的逻辑错误 #2556

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Risuntsy
Copy link

初始化时遍历的范围应该是weight[0]..=bag_size,而不是weight[0]..=weight.len() 原代码能运行是因为测试用例中的数值刚好不会对结果造成影响,如果将用例中的bag_size改为1则运行时会越界访问数组 在线运行示例: playground

初始化时遍历的范围应该是`weight[0]..=bag_size`,而不是`weight[0]..=weight.len()`
原代码能运行是因为测试用例中的数值刚好不会对结果造成影响,如果将用例中的`bag_size`改为1则运行时会越界访问数组
在线运行示例:  [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f887389636209a28fa29d7ba93fbcd59)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant