class Solution(object):
ans=[]
cur=[]
ansSet=set()
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
self.ansSet.clear()
self.ans=[]
self.ans.append([])
self.cur=[]
nums.sort()
self.dfs(nums)
for i in self.ansSet:
self.ans.append(list(i))
return self.ans
def dfs(self,nums):
Len=len(nums)
if self.cur!=[]:
#self.ans.append(self.cur[:])
self.ansSet.add(tuple(self.cur[:]))
for i in range(Len):
self.cur.append(nums[i])
self.dfs(nums[i+1:])
self.cur.pop()