78. 子集

1
2
3
4
5
6
7
8
9
10
11
12
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
path,result = [],[]
def split_tree(nums,start_index) ->List[List[int]]:
result.append(path.copy())
if start_index >= len(nums): return
for i in range(start_index,len(nums)):
path.append(nums[i])
split_tree(nums,i+1)
path.pop()
return result
return split_tree(nums,0)