78.给定一组不含重复元素的数组,返回该数组所有可能子集

class Solution(object):
    def subsets(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        res = []
        res.append([])
        def helper(resed,nums):
            if len(nums) == 0:
                return
            for i in range(len(nums)):
                new_resed = resed+[nums[i]]
                res.append(new_resed)
                new_nums = nums[i+1:]
                helper(new_resed,new_nums)
        helper([],nums)
        return res

你可能感兴趣的:(78.给定一组不含重复元素的数组,返回该数组所有可能子集)