Description
Given a list of numbers with duplicate number in it. Find all?unique?permutations.
Example
Example 1:
Input: [1,1]
Output:
[
? [1,1]
]
Example 2:
Input: [1,2,2]
Output:
[
? [1,2,2],
? [2,1,2],
? [2,2,1]
]
Challenge
Using recursion to do it is acceptable. If you can do it without recursion, that would be great!
思路:
與沒有重復(fù)的全排列類似,只是多了一步去重舅巷,所以要先對數(shù)組排序羔味,然后如果一個數(shù)與它前面的數(shù)相等而它前面的數(shù)又不在排列中那么它也不應(yīng)該出現(xiàn)在排列中。
代碼: