47. Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,
[1,1,2] have the following unique permutations:
[
[1,1,2],
[1,2,1],
[2,1,1]
]

public class Solution {
    private List> ans = new ArrayList>();
    private Set> currentSet = new HashSet>();
    public List> permuteUnique(int[] nums) {
        Arrays.sort(nums);
      //  List result = new ArrayList();
        if(nums.length<=0||nums == null)
           return ans;
        dfs(0,nums);
        ans = new ArrayList>(currentSet);
        return ans;
    }
    
    void dfs(int start,int[] nums)
    {
        if(start == nums.length)
        {
            ArrayList temp = new ArrayList();
            for(int i=0;i

你可能感兴趣的:(47. Permutations II)