mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 23:28:29 +08:00
Update 0216.组合总和III.md
This commit is contained in:
@ -367,7 +367,7 @@ class Solution:
|
|||||||
|
|
||||||
def backtracking(self, targetSum, k, currentSum, startIndex, path, result):
|
def backtracking(self, targetSum, k, currentSum, startIndex, path, result):
|
||||||
if currentSum > targetSum: # 剪枝操作
|
if currentSum > targetSum: # 剪枝操作
|
||||||
return # 如果path的长度等于k但currentSum不等于targetSum,则直接返回
|
return # 如果currentSum已经超过targetSum,则直接返回
|
||||||
if len(path) == k:
|
if len(path) == k:
|
||||||
if currentSum == targetSum:
|
if currentSum == targetSum:
|
||||||
result.append(path[:])
|
result.append(path[:])
|
||||||
|
Reference in New Issue
Block a user