My Python AC Solution Using Utility Function


  • 0
    J
    class Solution(object):
        def subsets(self, nums):
            """
            :type nums: List[int]
            :rtype: List[List[int]]
            """
            result = []
            temp = []
            
            self.util(0, len(nums)-1, nums, result, temp)
            
            return result
            
        def util(self, start, end, nums, result, temp):
            
            if start > end:
                result.append(temp)
                return
    
            self.util(start+1, end, nums, result, temp)
            self.util(start+1, end, nums, result, temp+[nums[start]])
            
            return
    
    if __name__=='__main__':
    
        a = [1,2,3]
        so = Solution()
    

Log in to reply
 

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