1class Solution:2def subsetsWithDup(self, nums: List[int]) -> List[List[int]]:3ans = []4nums.sort()56def subset(p, up):7if len(up) == 0:8if p not in ans:9ans.append(p)10return11ch = up[0]12subset(p + [ch], up[1:])13subset(p, up[1:])1415subset([], nums)16return ans