mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update
This commit is contained in:
@ -149,6 +149,7 @@
|
||||
* [回溯算法:排列问题(二)](https://mp.weixin.qq.com/s/9L8h3WqRP_h8LLWNT34YlA)
|
||||
* [本周小结!(回溯算法系列三)](https://mp.weixin.qq.com/s/tLkt9PSo42X60w8i94ViiA)
|
||||
|
||||
|
||||
(持续更新中....)
|
||||
|
||||
# LeetCode 刷题攻略
|
||||
|
@ -56,10 +56,13 @@ candidates 中的每个数字在每个组合中只能使用一次。
|
||||
|
||||
回看一下题目,元素在同一个组合内是可以重复的,怎么重复都没事,但两个组合不能相同。
|
||||
|
||||
|
||||
**所以我们要去重的是同一树层上的“使用过”,同一树枝上的都是一个组合里的元素,不用去重**。
|
||||
|
||||
为了理解去重我们来举一个例子,candidates = [1, 1, 2], target = 3,(方便起见candidates已经排序了)
|
||||
|
||||
**强调一下,树层去重的话,需要对数组排序!**
|
||||
|
||||
选择过程树形结构如图所示:
|
||||
|
||||
<img src='../pics/40.组合总和II.png' width=600> </img></div>
|
||||
|
Reference in New Issue
Block a user