human
I am working on the file "00_strStr.ipynb".
The first task is:
Given a list of numbers that may has duplicate numbers, return all possible subsets
Can you write Python program for it?
 Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.

class Solution:
    """
    @param S: A set of numbers.
    @return: A list of lists. All valid subsets.
    """
    def subsetsWithDup(self, S):
        # write your code here
        res = [[]]
        S.sort()
        for i in range(len(S)):
            if i == 0 or S[i] != S[i-1]:
                l = len(res)
            for j in range(len(res)-l, len(res)):
                res.append(res[j] + [S[i]])
        return res

Solution().subsetsWithDup([1,2,2])