Simple python solution without extra space.
class Solution:\n        # @param num, a list of integer\n        # @return a list of lists of integer\n        def subsetsWithDup(self, S):\n            res = 
    class Solution:\n        # @param num, a list of integer\n        # @return a list of lists of integer\n        def subsetsWithDup(self, S):\n            res = [[]]\n            S.sort()\n            for i in range(len(S)):\n                if i == 0 or S[i] != S[i - 1]:\n                    l = len(res)\n                for j in range(len(res) - l, len(res)):\n                    res.append(res[j] + [S[i]])\n            return res\n\nif S[i] is same to S[i - 1], then it needn't to be added to all of the subset, just add it to the last l subsets which are created by adding S[i - 1]
['Python']