Combination Sum
Given asetof candidate numbers (C)(without duplicates)and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.
Thesamerepeated number may be chosen fromCunlimited number of times.
Note:
All numbers (including target) will be positive integers.
The solution set must not contain duplicate combinations.
For example, given candidate set[2, 3, 6, 7]
and target7
,
A solution set is:
分析
带有pos的DFS,没pos的话会把233和332看成不同的path,导致最后结果有重复。
可能以后除了Permutation外,都要带pos来去重复。
DFS可以从当前i开始,因为允许当前元素重复。
Last updated