class Solution {
public:
vector<vector<int>> combine(int n, int k) {
vector<vector<int>> res;
vector<int> record;
combination(res, record, n, k, 0);
return res;
}
private:
void combination(vector<vector<int>>& res, vector<int>& record, int n, int k, int start) {
if (record.size() == k) {
res.push_back(record);
return;
}
for (int i = start; i < n ; i++) {
record.push_back(i + 1);
combination(res, record, n, k, i + 1);
record.pop_back();
}
}
};