128. Subsets II

Given an integer array nums, which can have duplicate entries, provide the power set.

Duplicate subsets cannot exist in the solution set. Return the answer in any sequence.

Example 1:

Input : nums = [1, 2, 2]

Output : [ [ ] , [1] , [1, 2] , [1, 2, 2] , [2] , [2, 2] ]

Example 2:

Input : nums = [1, 2]

Output : [ [ ], [1] , [2] , [1, 2] ]

Now Your Turn!

Pick the correct output for the given input

Input : nums = [1, 3, 3]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= nums.length <= 10
  • -10 <= nums[i] <= 10

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
vector<vector<int> > subsetsWithDup(vector<int>& nums) {
//your code goes here
}
};
Test Case

Input:

Nums