Subsets II
Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets; the subsets may be returned in any order.
Open official problem prompt ↗List every distinct subset of a multiset exactly once.
Choosing any assortment of toppings where two jars hold the same topping; a plate with 'one of that topping' is the same plate no matter which jar you scooped from, so you count it once.
- Input
- nums = [1,2,2]
- Output
- [[],[1],[1,2],[1,2,2],[2],[2,2]]
- Why
- These are the six distinct subsets of the multiset {1,2,2}; picking either 2 alone yields the same subset [2], counted once.
1 <= nums.length <= 10-10 <= nums[i] <= 10