```
class Solution(object):
def do_subsets(self, nums, prefix, answer):
answer.append(prefix)
for i,num in enumerate(nums):
self.do_subsets(nums[i+1:] , prefix + [num], answer)
return answer
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
# sort to avoid adding same subset more than once
return self.do_subsets(sorted(nums), [], [])
```