[LeetCode][Python3] 47. Permutations II
2019. 8. 18. 23:08 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/permutations-ii/
My Solution :
class Solution:
def permuteUnique(self, nums):
def backtrack():
if len(path) == len(nums):
ret.append(path[:])
else:
for n in counter:
if counter[n]:
path.append(n)
counter[n] -= 1
backtrack()
path.pop()
counter[n] += 1
counter = {}
for n in nums:
counter[n] = counter.get(n, 0) + 1
path, ret = [], []
backtrack()
return ret
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 52. N-Queens II (0) | 2019.08.23 |
---|---|
[LeetCode][Python3] 526. Beautiful Arrangement (0) | 2019.08.21 |
[LeetCode][Python3] 784. Letter Case Permutation (0) | 2019.08.20 |
[LeetCode][Python3] 980. Unique Paths III (0) | 2019.08.20 |
[LeetCode][Python3] 1079. Letter Tile Possibilities (0) | 2019.08.16 |
[LeetCode][Python3] 765. Couples Holding Hands (0) | 2019.08.15 |
[LeetCode][Python3] 854. K-Similar Strings (0) | 2019.08.15 |
[LeetCode][Python3] 5. Longest Palindromic Substring (0) | 2019.04.30 |
최근에 달린 댓글 최근에 달린 댓글