leetcode 77. Combinations

来源:互联网 发布:网络教育学历 编辑:程序博客网 时间:2024/05/22 01:31
class Solution {public:vector<vector<int>> combine(int n, int k){a = n;process({}, 1, k);return res;}private:vector<vector<int>> res;int a;void process(vector<int> temp, int m, int k){if (k == 0){res.push_back(temp);return;}for (int i = m; i <= a; i++){temp.push_back(i);process(temp, i + 1, k - 1);temp.pop_back();}}};

0 0
原创粉丝点击