java 1ms simple solution
\npublic void traverse(List<List<Integer>> resultList, List<Integer> currentList, int index, int[] nums) {\n    resultList.add(new ArrayList<Integer>(currentLis
```\npublic void traverse(List<List<Integer>> resultList, List<Integer> currentList, int index, int[] nums) {\n    resultList.add(new ArrayList<Integer>(currentList)); // 3. add currentList to final result list\n    for(int i = index; i < nums.length; i++) {\n        if( i > index && nums[i] == nums[i - 1] ) // 2. duplicate removal\n            continue;\n        currentList.add(nums[i]);\n        traverse(resultList, currentList, i + 1, nums);\n        currentList.remove(currentList.size() - 1);\n    }\n}\n\npublic List<List<Integer>> subsetsWithDup(int[] nums) {\n    Arrays.sort(nums); // 1. sort the array\n    List<List<Integer>> resultList = new ArrayList<List<Integer>>();\n    traverse(resultList, new ArrayList<Integer>(), 0, nums);\n    return resultList;\n}\n```
['Backtracking', 'Java']