1 class Solution 2 { 3 public: 4 vector> combinationSum(vector & candidates, int target) 5 { 6 sort(candidates.begin(),candidates.end()); 7 vector > res; 8 vector cur; 9 help(res,cur,candidates,target,0);10 return res;11 }12 13 void help(vector >&res,vector &cur,vector &candidates,int target,int index)14 {15 if(target<0)16 return;17 if(target==0)18 {19 res.push_back(cur);20 return;21 } 22 int sz=candidates.size();23 for(int i=index;i
这个题,回溯法,很重要,那个pop_back()好好理解