2.注意剪枝为递归出口
class Solution {
public:
vector<vector<int>>count;
vector<int>path;
void dfs(int n,int k,int start)
{
if(path.size()==k)
{
count.push_back(path);
}
for(int i=start;i<=n;i++)
{
path.push_back(i);
dfs(n,k,i+1);
path.pop_back();
}
}
vector<vector<int>> combine(int n, int k) {
dfs(n,k,1);
return count;
}
};