mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-03 05:27:55 +08:00
fix: check the rust codes and fix them (#653)
* fix: check the rust codes and fix it * Update binary_tree_bfs.rs --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
@ -33,7 +33,7 @@ fn subset_sum_i(nums: &mut [i32], target: i32) -> Vec<Vec<i32>> {
|
||||
let state = Vec::new(); // 状态(子集)
|
||||
nums.sort(); // 对 nums 进行排序
|
||||
let start = 0; // 遍历起始点
|
||||
let mut res = Vec::new();
|
||||
let mut res = Vec::new(); // 结果列表(子集列表)
|
||||
backtrack(state, target, nums, start, &mut res);
|
||||
res
|
||||
}
|
||||
|
||||
@ -29,8 +29,8 @@ fn backtrack(mut state: Vec<i32>, target: i32, total: i32, choices: &[i32], res:
|
||||
/* 求解子集和 I(包含重复子集) */
|
||||
fn subset_sum_i_naive(nums: &[i32], target: i32) -> Vec<Vec<i32>> {
|
||||
let state = Vec::new(); // 状态(子集)
|
||||
let total = 0;
|
||||
let mut res = Vec::new();
|
||||
let total = 0; // 子集和
|
||||
let mut res = Vec::new(); // 结果列表(子集列表)
|
||||
backtrack(state, target, total, nums, &mut res);
|
||||
res
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ fn subset_sum_ii(nums: &mut [i32], target: i32) -> Vec<Vec<i32>> {
|
||||
let state = Vec::new(); // 状态(子集)
|
||||
nums.sort(); // 对 nums 进行排序
|
||||
let start = 0; // 遍历起始点
|
||||
let mut res = Vec::new();
|
||||
let mut res = Vec::new(); // 结果列表(子集列表)
|
||||
backtrack(state, target, nums, start, &mut res);
|
||||
res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user