Python : 2 lines - recursive


  • 0
    A
        def subsets(self, nums, accum = []):
            if len(nums) == 0 : return [accum]
            return self.subsets(nums[1:], accum + [nums[0]]) + self.subsets(nums[1:], accum) 
    

Log in to reply
 

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