class Solution {
public:
vector<vector<int>>result;
vector<int>path;
void backtracing(int n,int k,int start)
{
if(path.size()==k)
{
result.push_back(path);
return;
}
for(int i=start;i<=n;i++)
{
path.push_back(i);
backtracing(n, k, i+1);
path.pop_back();
}
}
vector<vector<int>> combine(int n, int k) {
backtracing(n, k, 1);
return result;
}
};
代码随想录第二十四天|77.组合
最新推荐文章于 2024-10-31 16:16:13 发布