Skip to content

Instantly share code, notes, and snippets.

@Awlter
Created March 8, 2020 03:52
Show Gist options
  • Save Awlter/f450349acba430ca1b3619b43da6625b to your computer and use it in GitHub Desktop.
Save Awlter/f450349acba430ca1b3619b43da6625b to your computer and use it in GitHub Desktop.
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
res = []
self.dfs(res, nums)
return res
def dfs(self, res, nums, list = [], index = 0):
if index == len(nums):
print(list)
res.append(list)
return
self.dfs(res, nums, list, index + 1)
list.append(nums[index])
self.dfs(res, nums, list, index + 1)
list.pop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment