Merge pull request #2879 from lewiseng/patch-1

Update 0216.组合总和III.md
This commit is contained in:
程序员Carl
2025-05-19 17:46:22 +08:00
committed by GitHub

View File

@ -365,7 +365,7 @@ class Solution:
def backtracking(self, targetSum, k, currentSum, startIndex, path, result):
if currentSum > targetSum: # 剪枝操作
return # 如果path的长度等于k但currentSum不等于targetSum则直接返回
return # 如果currentSum已经超过targetSum则直接返回
if len(path) == k:
if currentSum == targetSum:
result.append(path[:])