-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombinations.cc
More file actions
45 lines (37 loc) · 761 Bytes
/
Copy pathCombinations.cc
File metadata and controls
45 lines (37 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <sstream>
#include <iostream>
#include <stack>
#include <vector>
#include <iterator>
#include <numeric>
using namespace std;
class Solution{
private:
std::vector<std::vector<int> > ret;
std::vector<int> a;
public:
void solve(int dep, int maxDep, int n, int start){
if( dep == maxDep ){
ret.push_back(a);
return;
}
for(int i = start; i <= n; ++i){
a[dep] = i;
solve(dep + 1, maxDep, n, i+1);
}
}
std::vector<std::vector<int> > combine(int n, int k ){
a.resize(k);
ret.clear();
solve(0, k, n, 1);
return ret;
}
};
int main(int argc, char const *argv[])
{
Solution s;
return 0;
}