LeetCode78. 子集
题目链接
https://leetcode.cn/problems/subsets/description/
代码
python
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
result = []
self.backtracking(nums, result, 0, [])
return result
def backtracking(self, nums, result, index, path):
result.append(path[:])
for i in range(index, len(nums)):
path.append(nums[i])
self.backtracking(nums, result, i + 1, path)
path.pop()