39 Combination Sum
Last updated
Was this helpful?
Last updated
Was this helpful?
Given a set of 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:
(1) Backtracking
Backtracking: 时间复杂度O(2^n), 空间复杂度O(2^n)