标签:des style blog color java os strong io
题目:
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:
10,1,2,7,6,1,5
and target 8
, [1, 7]
[1, 2, 5]
[2, 6]
[1, 1, 6]
题解:
这道题跟combination sum本质的差别就是当前已经遍历过的元素只能出现一次。
所以需要给每个candidate一个visited域,来标识是否已经visited了。
当回退的时候,记得要把visited一起也回退了。
代码如下:
Combination Sum II leetcode java,布布扣,bubuko.com
Combination Sum II leetcode java
标签:des style blog color java os strong io
原文地址:http://www.cnblogs.com/springfor/p/3886057.html