递归
python">class Solution:def __init__(self):self.nums = Noneself.size = Noneself.res = []def dfs(self, ans, x=0):if ans.copy() not in self.res:self.res.append(ans.copy())for i in range(x, self.size):ans.append(self.nums[i])self.dfs(ans, i + 1)ans.pop()def subsetsWithDup(self, nums):self.nums = sorted(nums)self.size = len(nums)self.dfs([])return self.res
同力扣 78. 子集