leetcode.com/problems/subsets/
Subsets - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
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
댓글