public class Solution {
public List<List<Integer>> subsetsWithDup(int[] nums) {
List<List<Integer>> list = new ArrayList<>();
if(nums == null){
return list;
}
Arrays.sort(nums);
helper(list, new ArrayList<>(), nums, 0);
return list;
}
private void helper(List<List<Integer>> list, List<Integer> temp, int[] nums, int start){
if(!list.contains(temp)){
list.add(new ArrayList<>(temp));
}
for(int i = start; i < nums.length; i++){
temp.add(nums[i]);
helper(list, temp, nums, i + 1);
temp.remove(temp.size() - 1);
}
}
}
[LeetCode] 90. Subsets II
最新推荐文章于 2021-03-14 23:03:12 发布