You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.
*/
#include <vector>
using namespace std;
class Solution {
public:
vector<vector<int>> combinationsSum3(int k, int n) {
vector<vector<int>> ret;
vector<int> path;
findSum(k, n, path, ret, 1);
return ret;
}
void findSum(int k, int n, vector<int>& path, vector<vector<int>>& ret, int begin) {