MCPcopy Create free account
hub / github.com/TheAlgorithms/Rust / permute_unique

Function permute_unique

src/general/permutations/naive.rs:37–47  ·  view source on GitHub ↗

A common variation of generating permutations is to generate only unique permutations Of course, we could use the version above together with a Set as collector instead of a Vec. But let's try something different: how can we avoid to generate duplicated permutations in the first place, can we tweak the algorithm above?

(arr: &[T])

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 1

test_unique_valuesFunction · 0.85

Calls 3

permute_recurse_uniqueFunction · 0.85
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by 1

test_unique_valuesFunction · 0.68