143. Leetcode 78. 子集 (回溯算法-子集问题)
生活随笔
收集整理的這篇文章主要介紹了
143. Leetcode 78. 子集 (回溯算法-子集问题)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
class Solution:def subsets(self, nums: List[int]) -> List[List[int]]:res = []def dfs(nums, start_index, path):res.append(path[:])for i in range(start_index, len(nums)):path.append(nums[i])dfs(nums, i + 1, path)path.pop()dfs(nums,0,[])return res?
總結(jié)
以上是生活随笔為你收集整理的143. Leetcode 78. 子集 (回溯算法-子集问题)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 142. Leetcode 93. 复原
- 下一篇: 146. Leetcode 51. N