[LeetCode][Python3] 39. Combination Sum
2019. 8. 23. 23:19 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/combination-sum/
My Solution :
class Solution:
def combinationSum(self, candidates, target):
def dfs(path, remain, i):
if remain == 0:
ans.append(path[:])
return
if i < len(candidates) and candidates[i] <= remain:
dfs(path + [candidates[i]], remain-candidates[i], i)
dfs(path, remain, i+1)
candidates.sort()
ans = []
dfs([], target, 0)
return ans
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 357. Count Numbers with Unique Digits (0) | 2019.08.29 |
---|---|
[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] 216. Combination Sum III (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 |
최근에 달린 댓글 최근에 달린 댓글