mediumNeetCode 150
Subsets II
Given an integer array that may contain duplicates Return all possible unique subsets (the power set) Example: nums = [1,2,2] => [[],[1],[1,2],[1,2,2],[2],[2,2]]
Sorting first is what makes duplicates visible. I skip a repeated value at the same depth, so no subset shows up twice.

Meet Coco
Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit, and to talk with her for one hour. After that, talking comes with the $79 pack. Anyone can open the editor and run their code.
1Generate All Unique Subsets (With Duplicates)medium
Based onLeetCode