Update notes for s0040
This commit is contained in:
@@ -14,7 +14,7 @@ void combinationSum2DFS(vector<int> &candidates, int target, int startIndex,
|
||||
for (int i = startIndex; i < size; ++i) {
|
||||
// 剪枝,当现在节点的 sum 已经超过了 target,就没必要继续迭代了
|
||||
if (sum + candidates[i] > target) break;
|
||||
// 剪枝,要对同一树层使用过的元素进行跳过
|
||||
// 剪枝,但保留树枝重复的情况
|
||||
if (i > 0 && candidates[i] == candidates[i - 1] && used[i - 1] == false)
|
||||
continue;
|
||||
path.push_back(candidates[i]);
|
||||
|
Reference in New Issue
Block a user