52 millisecond Python


  • 0
    B
    class Solution(object):
        def subsets(self, nums):
            """
            :type nums: List[int]
            :rtype: List[List[int]]
            """
            l = [[]]
            if nums is None:
                return l
            nums.sort()
            l.append([nums[0]])
            
            for i in range(1, len(nums), 1):
                lenl = len(l)
                for j in range(0,lenl,1):
                    tmp = l[j]+[nums[i]]
                    l.append(tmp)
            return l

Log in to reply
 

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