mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 03:36:29 +08:00
fix(backtracking): minor mistake in Rust code for subset_sum_ii (#1487)
* fix(backtracking): minor mistake in Rust code for subset_sum_ii * Update subset_sum_ii.rs --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
parent
8a6ce26f6a
commit
2cd2a94ce6
2 changed files with 2 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue