Subsets II Java Solution || 2 lines added in Subsets I problem
\nclass Solution {\n    public List<List<Integer>> subsetsWithDup(int[] nums) {\n        Arrays.sort(nums);\n        List<Integer> subset = new ArrayList<>();\n
```\nclass Solution {\n    public List<List<Integer>> subsetsWithDup(int[] nums) {\n        Arrays.sort(nums);\n        List<Integer> subset = new ArrayList<>();\n        List<List<Integer>> ans = new ArrayList<>();\n        helper(nums,0,ans,subset);\n        return ans;\n    }\n        public void helper(int[] nums, int index, List<List<Integer>> ans, List<Integer> subset)\n    {\n        \n        if(index==nums.length)\n        {\n            ans.add(new ArrayList(subset));\n            return;\n        }\n        \n        //include\n        subset.add(nums[index]);\n        helper(nums,index+1,ans,subset);\n        \n        //exclude\n            while(index+1<nums.length && nums[index]==nums[index+1]){\n                index++;\n            }\n        subset.remove(subset.size()-1);\n        helper(nums,index+1,ans,subset);\n    }\n}\n```
['Java']