Skip to content

Commit 0c8ec83

Browse files
Update combination_sum.py
1 parent 733cec3 commit 0c8ec83

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

backtracking/combination_sum.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ def combination_sum(candidates: list, target: int) -> list:
5353
...
5454
ValueError: Candidates list should not be empty
5555
"""
56-
path = [] # type: list[int]
57-
answer = [] # type: list[int]
5856
if not candidates:
5957
raise ValueError("Candidates list should not be empty")
6058

6159
if any(x < 0 for x in candidates):
6260
raise ValueError("All elements in candidates must be non-negative.")
61+
62+
path = [] # type: list[int]
63+
answer = [] # type: list[int]
6364
backtrack(candidates, path, answer, target, 0)
6465
return answer
6566

0 commit comments

Comments
 (0)