class Solution(object):
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
if nums==None:
return []
elif nums==[]:
return [[]]
res=[]
self.helper(nums,[],res,0)
return res
def helper(self,nums,tmp,res,i):
if i==len(nums):
res.append(tmp[:])
return
self.helper(nums,tmp,res,i+1)
tmp.append(nums[i])
self.helper(nums,tmp,res,i+1)
tmp.remove(tmp[1])
Easy Python Solution


@mada0304 why do you append tmp[:] instead of tmp? I thought they were the same but append tmp does not work.
