```
enter code here
class Solution {
public:
vector<vector<int>> res;
vector<int> path;
public:
vector<vector<int>> combinationSum(vector<int>& can, int target) {
sort(can.begin(),can.end());
dfs(can,target,0);
return res;
}
void dfs(vector<int>& can,int target,int begin){
if(target==0){
res.push_back(path);
return ;
}
for(int i=begin;i<can.size()&&target-can[i]>=0;i++){
path.push_back(can[i]);
dfs(can,target-can[i],i);
path.pop_back();
}
}
};
```