MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / backtrack

Method backtrack

46-permutations.rs:22–33  ·  view source on GitHub ↗
(path: &mut Vec<i32>, ans: &mut Vec<Vec<i32>>, begin: usize)

Source from the content-addressed store, hash-verified

20 }
21
22 fn backtrack(path: &mut Vec<i32>, ans: &mut Vec<Vec<i32>>, begin: usize) {
23 if begin == path.len() {
24 ans.push(path.to_vec());
25 return;
26 }
27
28 for i in begin..path.len() {
29 path.swap(i, begin);
30 Self::backtrack(path, ans, begin + 1);
31 path.swap(i, begin);
32 }
33 }
34}
35
36fn main() {

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected