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:
Risun 2024-08-26 10:12:47 +08:00 committed by GitHub
parent 8a6ce26f6a
commit 2cd2a94ce6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -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();
}

View file

@ -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();
}