Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
Each number in C may only be used once in the combination.
Note:
All numbers (including target) will be positive integers.
The solution set must not contain duplicate combinations.
For example, given candidate set [10, 1, 2, 7, 6, 1, 5] and target 8,
A solution set is:
[
[1, 7],
[1, 2, 5],
[2, 6],
[1, 1, 6]
]
跟上一篇思想其实是一样的,只不过这个不能用同一水平线上即不能重复一个元素。上代码,递归自己写出来,看来还是懂了,嘿嘿。
public class Solution {

这篇博客讨论了LeetCode上的问题40,目标是找到一组不重复的候选数,使得它们的和等于给定的目标数。所有数字都是正整数,并且在组合中不能重复使用。博客作者通过递归方法解决了这个问题,并表示已经理解了算法的核心。
订阅专栏 解锁全文
266

被折叠的 条评论
为什么被折叠?



