From e1d0a28bddf573b83f88ab65fd47cf9d912de921 Mon Sep 17 00:00:00 2001 From: fw_qaq <82551626+fwqaaq@users.noreply.github.com> Date: Sat, 17 Dec 2022 23:04:18 +0800 Subject: [PATCH] =?UTF-8?q?update=200077.=E7=BB=84=E5=90=88=E4=BC=98?= =?UTF-8?q?=E5=8C=96.md=20=E5=85=B3=E4=BA=8E=20rust=20=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0077.组合优化.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/problems/0077.组合优化.md b/problems/0077.组合优化.md index 34318d16..066e1b33 100644 --- a/problems/0077.组合优化.md +++ b/problems/0077.组合优化.md @@ -267,22 +267,22 @@ Rust: ```Rust impl Solution { - fn backtracking(result: &mut Vec>, path: &mut Vec, n: i32, k: i32, startIndex: i32) { + fn backtracking(result: &mut Vec>, path: &mut Vec, n: i32, k: i32, start_index: i32) { let len= path.len() as i32; if len == k{ result.push(path.to_vec()); return; } // 此处剪枝 - for i in startIndex..= n - (k - len) + 1 { + for i in start_index..= n - (k - len) + 1 { path.push(i); Self::backtracking(result, path, n, k, i+1); path.pop(); } } pub fn combine(n: i32, k: i32) -> Vec> { - let mut result: Vec> = Vec::new(); - let mut path: Vec = Vec::new(); + let mut result = vec![]; + let mut path = vec![]; Self::backtracking(&mut result, &mut path, n, k, 1); result }