class Solution {public: vector> combinationSum(vector & candidates, int target) { vector > res; combinationSumDFS(candidates, target, 0, {}, res); return res; } void combinationSumDFS(vector & candidates, int target, int start, vector out, vector >& res) { if (target < 0) return; if (target == 0) {res.push_back(out); return;} for (int i = start; i < candidates.size(); ++i) { out.push_back(candidates[i]); combinationSumDFS(candidates, target - candidates[i], i, out, res); out.pop_back(); } }};