Problem :

https://leetcode.com/problems/subsets-ii/


My Solution :

class Solution:
    def subsetsWithDup(selfnums):
        nums.sort()
        ans = [[]]
        for i in range(len(nums)):
            if i == 0 or nums[i-1] != nums[i]:
                size = len(ans)
            for j in range(len(ans)-size, len(ans)):
                ans.append(ans[j]+[nums[i]])
        return ans