LeetCode78. 子集
- 题目链接
- 代码
题目链接
https://leetcode.cn/problems/subsets/description/
代码
class Solution:def subsets(self, nums: List[int]) -> List[List[int]]:result = []self.backtracking(nums, result, 0, [])return resultdef 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()