반응형
leetcode.com/problems/subsets/
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
result = []
def dfs(path, lst):
result.append(path)
if not lst:
return
for num in lst:
dfs(path+[num], lst[lst.index(num)+1:])
dfs([],nums)
return result
댓글