
📖이 포스팅은 '파이썬 알고리즘 인터뷰 - 박상길님' 책을 보고 작성되었습니다.
😎문제 : https://leetcode.com/problems/subsets/submissions/
모든 부분 집합을 리턴하라
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
result = []
def DFS(index, path):
result.append(path)
for i in range(index, len(nums)):
DFS(i+1, path + [nums[i]])
DFS(0,[])
return result
'자료구조와 알고리즘 > 🥑알고리즘' 카테고리의 다른 글
[알고리즘][그래프] - 8. 코스 스케줄 (0) | 2022.04.01 |
---|---|
[알고리즘][그래프] - 7. 일정 재구성 (0) | 2022.04.01 |
[알고리즘][그래프] - 5. 조합의 합 (0) | 2022.03.30 |
[알고리즘][그래프] - 4. 조합 (0) | 2022.03.28 |
[알고리즘][그래프] - 3. 순열 (0) | 2022.03.28 |