题解 | #牛棚分组#

牛棚分组

https://www.nowcoder.com/practice/d5740e4dde3740828491236c53737af4

#include <vector>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param n int整型 
     * @param k int整型 
     * @return int整型vector<vector<>>
     */
     vector<vector<int>> res;
     vector<int> path;
     bool st[20]={false};
     void dfs(int u,int n,int k){
        if(path.size()==k){
            res.push_back(path);
            return;
        }
        for(int i=u;i<=n;i++){
            if(!st[i]){
                st[i]=true;
                path.push_back(i);
                dfs(i+1,n,k);
                path.pop_back();
                st[i]=false;
            }
        }
     }
    vector<vector<int> > combine(int n, int k) {
        dfs(1, n, k);
        return res;
    }
};

全部评论

相关推荐

码农索隆:这种hr,建议全中国推广
点赞 评论 收藏
分享
zhch7:建议9✌️把学历加黑加粗,如果实在offer可能是觉得佬不会去
投了多少份简历才上岸
点赞 评论 收藏
分享
见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
完美的潜伏者许愿简历...:隐藏信息被你提取出来了,暗示,这就是暗示
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务