Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations in any order.
Open official problem prompt ↗Produce every distinct ordering of a multiset without listing the same ordering twice.
Arranging labeled tiles in a row, except two tiles share the identical face; you agree to always place the leftmost unused identical tile first so mirror-image arrangements never get counted twice.
- Input
- nums = [1,1,2]
- Output
- [[1,1,2],[1,2,1],[2,1,1]]
- Why
- These are the three distinct orderings of the multiset {1,1,2}; swapping the two identical 1s produces no new permutation.
1 <= nums.length <= 8-10 <= nums[i] <= 10