80. Subsets II
[Medium] “Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set), without duplicate subsets."
Note: old solution, should review (TODO:
)
Python3:
class Solution:
def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:
res = [[]]
for num in nums:
size = len(res)
for i in range(size):
next_set = sorted(res[i] + [num])
if next_set not in res:
res.append(next_set)
return res