Subsets with duplicates
Given a list nums (length 1..10) that may contain duplicate integers, return all possible subsets (the power set) without any duplicate subsets. Each subset must be in non-decreasing order. Return the list of subsets sorted ascending; the empty subset is included.
Implement
subsets_with_dup(nums: list[int]) → list[list[int]]Examples
in
[[1,2,2]]out[[],[1],[1,2],[1,2,2],[2],[2,2]]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 20 min
solution.py
InputExpectedGot
[[1,2,2]][[],[1],[1,2],[1,2,2],[2],[2,2]]not run yetsample