One-Liner in Python


  • 0
    R
    class Solution(object):
        def subsetsWithDup(self, nums):
            """
            :type nums: List[int]
            :rtype: List[List[int]]
            """
            return reduce(lambda x,i: [ a+[i[0]]*j  for j in range(i[1]+1) for a in x], collections.Counter(nums).items(), [[]])
    

Log in to reply
 

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