Skip to content

Commit

Permalink
fix(backtracking): minor mistake in Rust code for subset_sum_ii (#1487)
Browse files Browse the repository at this point in the history
* fix(backtracking): minor mistake in Rust code for subset_sum_ii

* Update subset_sum_ii.rs

---------

Co-authored-by: Yudong Jin <[email protected]>
  • Loading branch information
Risuntsy and krahets authored Aug 26, 2024
1 parent 8a6ce26 commit 2cd2a94
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion codes/rust/chapter_backtracking/subset_sum_ii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn backtrack(
// 尝试:做出选择,更新 target, start
state.push(choices[i]);
// 进行下一轮选择
backtrack(state, target - choices[i], choices, i, res);
backtrack(state, target - choices[i], choices, i + 1, res);
// 回退:撤销选择,恢复到之前的状态
state.pop();
}
Expand Down
2 changes: 1 addition & 1 deletion zh-hant/codes/rust/chapter_backtracking/subset_sum_ii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn backtrack(
// 嘗試:做出選擇,更新 target, start
state.push(choices[i]);
// 進行下一輪選擇
backtrack(state.clone(), target - choices[i], choices, i, res);
backtrack(state.clone(), target - choices[i], choices, i + 1, res);
// 回退:撤銷選擇,恢復到之前的狀態
state.pop();
}
Expand Down

0 comments on commit 2cd2a94

Please sign in to comment.