###### leetcode 39: Combination Sum
class Solution {
public:
vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
vector<vector<int> > res;
vector<int> set;
sort(candidates.begin(),candidates.end());
helper(candidates,0,target,set,res);
return res;
}
void helper(vector<int>& candidates,int idx,int target,vector<int>& set,vector<vector<int> >& res){
for(int i=idx;i<candidates.size()&&candidates[i]<=target;i++)
{
set.push_back(candidates[i]);
if(candidates[i]==target)
{
res.push_back(set);
set.pop_back();
break;
}
else
{
helper(candidates,i,target-candidates[i],set,res);
set.pop_back();
}
}
}
};

#### [LeetCode39]Combination Sum

2014-06-17 04:15:23

#### [LeetCode]39.Combination Sum

2015-01-27 17:47:03

#### Leetcode #39. Combination Sum 组合求和 解题报告

2016-04-10 23:42:47

#### [leetcode]39. Combination Sum,python实现【Medium难度】

2016-06-16 17:01:20

#### leetcode 39. Combination Sum-回溯算法|递归|非递归

2016-03-15 17:37:26

#### LeetCode39:Combination Sum

2015-07-06 20:58:02

#### 回溯详解及其应用：Leetcode 39 combination sum

2017-01-31 16:47:37

#### LeetCode39——Combination Sum

2015-10-17 21:08:58

#### leetcode【39+40+216+377 Combination Sum 相关】【python】

2016-12-13 16:38:48

#### [leetcode-39]Combination Sum(java)

2015-07-31 11:02:36

## 不良信息举报

leetcode 39: Combination Sum