```
class Solution {
private:
vector<int> temp;
vector<vector<int>> result;
public:
vector<vector<int>> combine(int n, int k) {
combine( 1, n, k );
return result;
}
void combine( int begin, int n, int k ) {
if( !k )
{
result.push_back( temp );
return;
}
for( int i = begin; i <= n; i++ )
{
temp.push_back( i );
combine( i + 1, n, k - 1 );
temp.pop_back();
}
}
};
```