# Leetcode 78. Subsets ## 題解 ### DFS Back Tracking ```python! class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: n = len(nums) output = [] def dfs(start: int, ans: List[int]): output.append(ans[:]) for i in range(start,n): ans.append(nums[i]) dfs(i+1,ans) ans.pop() dfs(0,[]) return output ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up