Backtracking Subsets II Estimated reading: 1 minute 29 views You are given an array nums of integers, which may contain duplicates. Return all possible subsets.Example 1:Input: nums = [1,2,1] Output: [[],[1],[1,2],[1,1],[1,2,1],[2]] public List> subsetsWithDup(int[] nums) { List> res = new ArrayList<>(); Arrays.sort(nums); backtrack(0, new ArrayList<>(), nums, res); return res; } private void backtrack(int start, List subset, int[] nums, List> res) { res.add(new ArrayList<>(subset)); for (int i = start; i < nums.length; i++) { if (i > start && nums[i] == nums[i - 1]) { continue; } subset.add(nums[i]); backtrack(i + 1, subset, nums, res); subset.remove(subset.size() - 1); } }