78. 子集
套模板,可参考:https://www.cnblogs.com/panweiwei/p/14025143.html
class Solution(object):
def __init__(self):
self.res = []
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
if not nums:
return []
n = len(nums)
self.dfs(nums, n, 0, [])
return self.res
def dfs(self, nums, n, begin, temp):
self.res.append(temp)
for i in range(begin, n):
self.dfs(nums, n, i + 1, temp + [nums[i]])