给定一个可包含重复数字的整数集合 nums ,按任意顺序 返回它所有不重复的全排列。
示例 1:
输入:nums = [1,1,2]
输出:
[[1,1,2],
[1,2,1],
[2,1,1]]
示例 2:
输入:nums = [1,2,3]
输出:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
提示:
1 <= nums.length <= 8
-10 <= nums[i] <= 10
代码:
class Solution {
public List> permuteUnique(int[] nums) {
List> result=new linkedList<>();
helper(nums,0,result);
return result;
}
public void helper(int[] nums,int i,List> result){
if (i==nums.length)
{
List permutation=new linkedList<>();
for (int k=0;k set=new HashSet<>();
for (int j=i;j



