Python solution, beats 100%


  • 0
    S
        def helper(self, res, nums, index):
            if index == len(nums):
                return res
                
            for i in range(len(res)):
                res.append(res[i][:])
                res[len(res)-1].append(nums[index])
    
            index += 1
            return self.helper(res, nums, index)
    
        def subsets(self, nums):
            """
            :type nums: List[int]
            :rtype: List[List[int]]
            """
            res = [[]]
            nums.sort()
            return self.helper(res, nums, 0)

Log in to reply
 

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