Created
October 31, 2020 12:28
-
-
Save inspirit941/472ecb4ee90e3f7a3ebd75f97aa1e92d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def subsets(self, nums: List[int]) -> List[List[int]]: | |
# 트리 구조의 dfs로 해결하기 | |
result = [] | |
def dfs(idx, path): | |
result.append(path) | |
# idx 순서대로 경로를 만들면서 dfs 연산 | |
for next_idx in range(idx, len(nums)): | |
dfs(next_idx + 1, path + [nums[next_idx]]) | |
dfs(0, []) | |
return result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment