[LeetCode][Python3] 216. Combination Sum III
2019. 8. 23. 21:25 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/combination-sum-iii/
My Solution :
class Solution:
def combinationSum3(self, k, n):
def dfs(k, n, path, num):
if k == 0 or n < num or 9 < num:
if k == n == 0:
ans.append(path[:])
return
dfs(k-1, n-num, path+[num], num+1)
dfs(k, n, path, num+1)
ans = []
dfs(k, n, [], 1)
return ans
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 996. Number of Squareful Arrays (0) | 2019.08.28 |
---|---|
[LeetCode][Python3] 174. Dungeon Game (0) | 2019.08.28 |
[LeetCode][Python3] 77. Combinations (0) | 2019.08.25 |
[LeetCode][Python3] 39. Combination Sum (0) | 2019.08.23 |
[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 |
최근에 달린 댓글 최근에 달린 댓글