diff --git a/codes/rust/chapter_backtracking/subset_sum_ii.rs b/codes/rust/chapter_backtracking/subset_sum_ii.rs index d3c6f4319..389bae711 100644 --- a/codes/rust/chapter_backtracking/subset_sum_ii.rs +++ b/codes/rust/chapter_backtracking/subset_sum_ii.rs @@ -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(); } diff --git a/zh-hant/codes/rust/chapter_backtracking/subset_sum_ii.rs b/zh-hant/codes/rust/chapter_backtracking/subset_sum_ii.rs index 715922134..6638ee9fe 100644 --- a/zh-hant/codes/rust/chapter_backtracking/subset_sum_ii.rs +++ b/zh-hant/codes/rust/chapter_backtracking/subset_sum_ii.rs @@ -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(); }