Fastest python solution


  • -4
    Y
    import itertools
    class Solution(object):
    def subsets(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        res = [[]]
        for l in range(len(nums)):
            for item in itertools.combinations(nums, l+1):
                res.append(sorted(item))
        return res

Log in to reply
 

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