This commit is contained in:
youngyangyang04
2020-11-15 11:04:51 +08:00
parent c91672de81
commit 14d773ba19
2 changed files with 4 additions and 0 deletions

View File

@ -56,10 +56,13 @@ candidates 中的每个数字在每个组合中只能使用一次。
回看一下题目,元素在同一个组合内是可以重复的,怎么重复都没事,但两个组合不能相同。
**所以我们要去重的是同一树层上的“使用过”,同一树枝上的都是一个组合里的元素,不用去重**
为了理解去重我们来举一个例子candidates = [1, 1, 2], target = 3方便起见candidates已经排序了
**强调一下,树层去重的话,需要对数组排序!**
选择过程树形结构如图所示:
<img src='../pics/40.组合总和II.png' width=600> </img></div>