朝鲜报纸评<<蓝色生死恋>># Joke - 肚皮舞运动
g*j
1 楼
Combination Sum
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.
Elements in a combination must be in non-descending order.
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]
现在有几个结果过不去
比如
输入1,1, target 是 1 ,期待返回的结果应该是[[1]],但是我的程序返回的结果总
是[[1],[1]],
我开始以为把输入数据里面的重复去掉就行了,但是,根据测试集来看,输入的两个1
被当成两个不同的1,但是结果呢,[1] 和 [1] 又当成两个一样的1,请问如何解决这
个问题,这种重复如何在选的过程中去掉? 如果选完了再去掉重复,应该不好吧?
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.
Elements in a combination must be in non-descending order.
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]
现在有几个结果过不去
比如
输入1,1, target 是 1 ,期待返回的结果应该是[[1]],但是我的程序返回的结果总
是[[1],[1]],
我开始以为把输入数据里面的重复去掉就行了,但是,根据测试集来看,输入的两个1
被当成两个不同的1,但是结果呢,[1] 和 [1] 又当成两个一样的1,请问如何解决这
个问题,这种重复如何在选的过程中去掉? 如果选完了再去掉重复,应该不好吧?