MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / permute_unique

Method permute_unique

47. Permutations II/src/main.rs:8–19  ·  view source on GitHub ↗
(mut nums: Vec<i32>)

Source from the content-addressed store, hash-verified

6
7impl Solution {
8 pub fn permute_unique(mut nums: Vec<i32>) -> Vec<Vec<i32>> {
9 nums.sort();
10 let mut n = nums.clone();
11 let mut res = vec![];
12 res.push(n.clone());
13 Self::next_permutation(&mut n);
14 while n != nums {
15 res.push(n.clone());
16 Self::next_permutation(&mut n);
17 }
18 res
19 }
20
21 pub fn next_permutation(nums: &mut Vec<i32>) {
22 if nums.len() <= 1 { return }

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected