Skip to content

Commit b71ce6b

Browse files
committed
solve Combination Sum III
1 parent 6d32731 commit b71ce6b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

problems/combination_sum_iii.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def combinationSum3(self, k: int, n: int) -> List[List[int]]:
166166
ans = []
167167

168168
def dfs(
169-
path: List[int] = None, node: int = 1, path_sum: int = 0, path_len: int = 0
169+
path: List[int] = None, node: int = 0, path_sum: int = 0, path_len: int = 0
170170
):
171171
if path is None:
172172
path = []
@@ -178,10 +178,10 @@ def dfs(
178178
if path_sum > n or path_len > k:
179179
return
180180

181-
for child_node in range(node, 10):
181+
for child_node in range(node + 1, 10):
182182
dfs(
183183
path=path + [child_node],
184-
node=child_node + 1,
184+
node=child_node,
185185
path_sum=path_sum + child_node,
186186
path_len=path_len + 1,
187187
)

0 commit comments

Comments
 (0)