Distinct Arrangements
Return all distinct permutations of nums, in lexicographic order.
Constraints
Examples
EXAMPLE WALKTHROUGHduplicates
A guided view of the published example, not a trace of your code.
INPUT
[[1,1,2]]TASKdistinct_arrangements()
EXPECTED OUTPUT
[[1,1,2],[1,2,1],[2,1,1]]Start with the input values shown in this example.
Example 1 of 3
Input: nums = [1,1,2]
Output: [[1,1,2],[1,2,1],[2,1,1]]
Explanation: duplicates
Input: nums = [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Explanation: all distinct
Input: nums = []
Output: [[]]
Explanation: empty
Hint 1
Backtrack over a Counter of remaining values instead of positions; that naturally avoids duplicates.