mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Update the codes of backtracking.
This commit is contained in:
@ -21,6 +21,7 @@ void backtrack(vector<int> &state, const vector<int> &choices, vector<bool> &sel
|
||||
// 尝试:做出选择,更新状态
|
||||
selected[i] = true;
|
||||
state.push_back(choice);
|
||||
// 进行下一轮选择
|
||||
backtrack(state, choices, selected, res);
|
||||
// 回退:撤销选择,恢复到之前的状态
|
||||
selected[i] = false;
|
||||
|
||||
Reference in New Issue
Block a user