Given an integer array nums that MAY contain duplicates, return every possible UNIQUE subset. The example input is 122; the expected output contains 6 arrays — not 8, because two of B1's 8 ballots would collide on the same value-multiset.
B1 votes per INDEX, not per VALUE. On 122, 3 indices ⟶ 2×2×2 = 8 ballots, but two of those ballots ARE the same subset by value. Your job: prune exactly those collisions without dropping legitimate repeats like 22.
The subset algorithm we just learned works because each element gets one binary vote: in, or out. For n elements, that's 2^n ballots — each distinct, each captured exactly once. No duplicates possible. Except…
What if the input already contains repeats? The algorithm doesn't know nums[1] = 2 and nums[2] = 2 are the same value — it treats them as two distinct elements at different indices. Include one, exclude the other; exclude one, include the other. Two ballots produce the same subset.
Before we run it on 122 — commit to a prediction. When we run the same include/exclude algorithm on this input, how many outputs will it produce?
When we run B1's subsets algorithm on 122, how many outputs will it produce?