
missingPermutations
Given a list containing permutations of a set of characters, list all of the missing permutations in lexicographical order.
There can be multiple occurrences of the same permutation in the input. In the output, however, all of the permutations need to be unique.
Examples:
-
For
permutationList=["ab"]
, the output should bemissingPermutations(permutationList) = ["ba"]
.There are 2 permutations of
'a'
and'b'
:"ab"
and"ba"
. The only permutation missing from the input is"ba"
. -
For
permutationList=["bca", "bac", "acb"]
, the output should bemissingPermutations(permutationList) = ["abc", "cab", "cba"]
.There are 6 permutations of
'a'
,'b'
, and'c'
. The missing permutations, sorted lexicographically, are"abc"
,"cab"
and"cba"
. -
For
permutationList=["a"]
, the output should bemissingPermutations(permutationList) = []
.The result is empty since
"a"
is the only permutation of the set of letters consisting of a single letter'a'
.
Input/Output:
-
[execution time limit] 1 seconds
-
[input] array.string permutationList
permutationList.length ≥ 1
,0 ≤ permutationList[i].length ≤ 6
,permutationList[i].length = permutationList[j].length
,permutationList[i]
contains the same set of distinct characters for eachi
. -
[output] array.string
The list of missing permutations sorted in lexicographical order.
Post Comment