Link : https://leetcode.com/problems/permutations/
Python
더보기
1
2
3
4
5
6
7
8
9
10
11
12
|
class Solution:
def DFS(self, extra, result, deapth):
t_list = []
if len(extra) == 0:
return [result[:]]
for idx, val in enumerate(extra):
result[deapth] = val;
t_list += self.DFS(extra[:idx] + extra[idx + 1:], result, deapth + 1)
return t_list
def permute(self, nums: list[int]) -> list[list[int]]:
return self.DFS(nums, [None for _ in range(len(nums))], 0)
|
cs |
FeedBack
cjw.git@gmail.com
'알고리즘 > 소스코드' 카테고리의 다른 글
LEETCODE 287: Find the Duplicate Number (0) | 2021.08.05 |
---|---|
LEETCODE 128. Longest Consecutive Sequence (0) | 2021.08.05 |
PROGRAMMERS 49189: 가장 먼 노드 (0) | 2021.07.27 |
PROGRAMMERS 42861: 섬 연결하기 (0) | 2021.07.18 |
PROGRAMMERS 42842: 카펫 (0) | 2021.07.18 |
댓글