Given a list of numbers that may has duplicate numbers, return all possible subsets
Each element in a subset must be in non-descending order.
The ordering between two subsets is free.
The solution set must not contain duplicate subsets.
classSolution:""" @param S: A set of numbers. @return: A list of lists. All valid subsets. """defsubset_helper(self,numbers,solution,result):# insert get one solutionresult.append(solution[:])fori,eninenumerate(numbers):# remove duplicated casesifi>0andnumbers[i]==numbers[i-1]:continuesolution.append(en)# cut the dfsself.subset_helper(numbers[i+1:],solution,result)solution.pop()returndefsubsetsWithDup(self,S):# write your code hereresult=[]self.subset_helper(sorted(S),[],result)returnresultif__name__=="__main__":sol=Solution()print(sol.subsetsWithDup([0]))