90. Subsets II

public class Solution {
    public List> subsetsWithDup(int[] nums) {
        List> res=new ArrayList<>();
        if(nums.length==0) return res;
        Arrays.sort(nums);
        helper(res,nums,new ArrayList<>(),0);
        return res;
    }
    public void helper(List> res,int[] nums,List list,int start){
        res.add(new ArrayList<>(list));
        for(int i=start;istart&&nums[i]==nums[i-1]) continue;
            list.add(nums[i]);
            helper(res,nums,list,i+1);
            list.remove(list.size()-1);
        }
    }
}

你可能感兴趣的:(90. Subsets II)