일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- iterator
- t1
- Convert Sorted List to Binary Search Tree
- 시바견
- kaggle
- Generator
- DWG
- Substring with Concatenation of All Words
- 30. Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- Regular Expression
- shiba
- 43. Multiply Strings
- 컴퓨터의 구조
- Python Code
- concurrency
- Protocol
- Python Implementation
- Class
- LeetCode
- 109. Convert Sorted List to Binary Search Tree
- attribute
- 715. Range Module
- 파이썬
- Python
- data science
- 밴픽
- 운영체제
- Decorator
- 프로그래머스
Archives
- Today
- Total
Scribbling
LeetCode: 47. Permutations II 본문
class Solution:
def permuteUnique(self, nums: List[int]) -> List[List[int]]:
nums.sort()
self.ret = []
self.dfs(nums, [])
return self.ret
def dfs(self, nums, path):
if not nums:
self.ret.append(path)
return
prev = None
for i, num in enumerate(nums):
if num != prev:
self.dfs(nums[:i]+nums[i+1:], path+[num])
prev = num
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 49. Group Anagrams (0) | 2021.09.08 |
---|---|
LeetCode: 41. First Missing Positive (0) | 2021.09.08 |
LeetCode: 46. Permutations (0) | 2021.09.07 |
LeetCode: 40. Combination Sum II (0) | 2021.09.07 |
37. Sudoku Solver (0) | 2021.09.06 |