Test for change word to publish on cnblogs

0
14

test for change

 

 

private:

vector<vector<int>> res;

vector<int> path;

vector<int> candidates;

public:

 

void helper(int start,int target){

if (target<0){

return;

}else if(0==target){

res.push_back(path);

}else{

for(int i=start;i<candidates.size();i++){

if(candidates[i]<=target){

path.push_back(candidates[i]);

helper(i,target-candidates[i]);

path.pop_back();

}

}

}

}

vector<vector<int>> combinationSum(vector<int>& candidates, int target) {

 

sort(candidates.begin(),candidates.end());

vector<int> path;

this->candidates=candidates;

helper(0,target);

return res;

}

};

 

/*bool isexist(vector<vector<int>>& res, vector<int> path){

bool flag=false;

for(int i=0;i<res.size();i++){

for(int j=0;j<path.size();j++){

if(res[i][j]!=path[j]){

flag=false;

break;

}

else{

flag=true;

}

}

if(flag==true){

break;

}

}

return flag;

}*/

<

发布回复

请输入评论!
请输入你的名字