vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {
vector<int> res;
vector<vector<int>> allres;
sort(candidates.begin(),candidates.end());
combination(res,allres,0,target,candidates);
return allres;
}
void combination(vector<int> &res,vector<vector<int>> &allres,int begin,int target,vector<int>& candidates) {
if(target==0){
allres.push_back(res);
return;
}
for(int i=begin;i<candidates.size()&&candidates[i]<target;i++) {
if(i&&candidates[i]==candidates[i-1]&&i>begin) continue;
res.push_back(candidates[i]);
combination(res,allres,i+1,target-candidates[i],candidates);
res.pop_back();
}
}

why is it wrong? the result of run is null;