1class Solution:
2 def subsetsWithDup(self, nums):
3 if not nums:
4 return []
5 nums.sort()
6 res, cur = [[]], []
7 for i in range(len(nums)):
8 if i > 0 and nums[i] == nums[i-1]:
9 cur = [item + [nums[i]] for item in cur]
10 else:
11 cur = [item + [nums[i]] for item in res]
12 res += cur
13 return res
14