easy to understand in python 6 lines


  • 0
    W
        def subsets(self, nums):
            """
            :type nums: List[int]
            :rtype: List[List[int]]
            """
            results=[[]]
            for i in range(len(nums)):
                result=[x+[nums[i]] for x in results]
                results+=result
            return results
    

Log in to reply
 

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