已解答
中等
相关标签
相关企业
给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的
子集
(幂集)。
解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。
import copy
class Solution(object):
def subsets(self, nums):
"""
:type nums: Listint
:rtype: ListList\[int]
"""
if len(nums)==0:
return \[]
if len(nums)==1:
return \[nums\[0]]
right=self.subsets(nums1:)
rt = copy.deepcopy(right)
for sub in right:
rt.append(nums\[0] + sub)
return rt