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>
pull/1498/head^2
Risun 3 months ago committed by GitHub
parent 8a6ce26f6a
commit 2cd2a94ce6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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…
Cancel
Save