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