Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

For example,
If n = 4 and k = 2, a solution is:

[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],
[1,4],
]
DFS,递归
 class Solution {
public:
vector<vector<int> > ans;
vector<int> vi;
int k_start,n_start;
void DFS(int Count,int start)
{
if(Count== k_start)
{
ans.push_back(vi);
return;
}
for(int i=start;i<n_start;i++)
{
vi[Count] = i+;
DFS(Count+, i+);
}
}
vector<vector<int> > combine(int n, int k) {
ans.clear();
vi.resize(k);
k_start = k;
n_start = n;
DFS(,);
return ans;
}
};

最新文章

  1. JSON Accelerator真是个好东西...
  2. 使用DocX开源组件,实现动态数据的填充。
  3. HTMLTestRunner修改Python3的版本
  4. header的安全配置指南
  5. DataTable以列分组
  6. iOS部分其他知识
  7. Java类的加载、链接和初始化
  8. Handler具体解释系列(四)——利用Handler在主线程与子线程之间互发消息
  9. [PowerShell] Backup Folder and Files Across Network
  10. 【Unity3D自学记录】Unity3D网络之Socket聊天室初探
  11. android 自己定义通知栏遇到的问题
  12. 优秀Java程序员必须了解的GC工作原理(转)
  13. JavaScript系列文章:详解正则表达式之三
  14. python网络编程之网络主机信息
  15. Hibernate一对多双向关联映射
  16. js事件、事件流以及target、currentTarget、this那些事
  17. python 最大连续子数组的和
  18. vue脚手架---vue-cli
  19. moodle 笔记
  20. iOS pods编译原理

热门文章

  1. sysbench基准测试工具使用
  2. SDN openflow 学习小得
  3. t讯src的一点小秘密
  4. 打开当前目录的其他exe
  5. PHP 性能优化之 PHP-FPM
  6. easyui datagrid combobox下拉框获取数据问题
  7. Python与Go斐波那契数列
  8. 201671010127 2016-2017-11 Java图形用户界面设计技术
  9. ZPP002M可重复执行
  10. 快速上手Runtime(一)之消息机制