Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Solution(object):
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
nums = sorted(nums)
result = []
temp = []
self.backtrack(nums, result, temp, 0)
return result
def backtrack(self, nums, result, temp, start):
result.append(temp[:])
for i in range(start, len(nums)):
temp.append(nums[i])
self.backtrack(nums, result, temp, i + 1)
temp.pop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.