2 line python solution, beats 97%


  • 0
    M
    class Solution(object):
        def subsetsWithDup(self, nums):
            d = [[[k]*j for j in range(v+1)] for k,v in collections.Counter(nums).items()]
            return [[item for sublist in i for item in sublist] for i in itertools.product(*d)]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.