class Solution(object):
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
nums.sort()
res=[]
line=[]
self.helper(nums,res,line)
return res
def helper(self,nums,res,line):
res.append([x for x in line])
for i,x in enumerate(nums):
line.append(x)
self.helper(nums[i+1:],res,line)
line.pop()
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
nums.sort()
res=[]
line=[]
self.helper(nums,res,line)
return res
def helper(self,nums,res,line):
res.append([x for x in line])
for i,x in enumerate(nums):
line.append(x)
self.helper(nums[i+1:],res,line)
line.pop()