From 2cd2a94ce673abf80ce2421587cf4a7873396e24 Mon Sep 17 00:00:00 2001 From: Risun <79560036+Risuntsy@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:12:47 +0800 Subject: [PATCH] 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 --- codes/rust/chapter_backtracking/subset_sum_ii.rs | 2 +- zh-hant/codes/rust/chapter_backtracking/subset_sum_ii.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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(); }