[leetcode 77] Combinations
来源:互联网 发布:西安seo公司 编辑:程序博客网 时间:2024/06/06 13:56
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],]
class Solution {public: vector<vector<int> > combine(int n, int k) { vector<vector<int> > res; vector<int> cur; dfs(n, 1, k, cur, res); return res; } void dfs(int n, int start, int k, vector<int> &cur, vector<vector<int> > &res) { if (k == 0) { res.push_back(cur); return ; } if (start > n) { return ; } for (int i = start; i <= n; i++) { cur.push_back(i); dfs(n, i+1, k-1, cur, res); cur.pop_back(); } }};
0 0
- LeetCode 77 Combinations
- [leetcode 77] Combinations
- Leetcode NO.77 Combinations
- [leetcode] 77 Combinations
- [LeetCode 77]Combinations
- leetcode || 77、Combinations
- leetcode-77 Combinations
- LeetCode-77 Combinations(组合)
- Combinations - LeetCode 77
- leetcode 77:Combinations
- LeetCode(77) Combinations
- Leetcode #77 Combinations
- [leetcode-77]Combinations(java)
- leetcode 77: Combinations
- LeetCode(77) Combinations
- 【leetcode】【77】Combinations
- leetcode 77:Combinations
- 【LEETCODE】77-Combinations [Python]
- 第二章 Spring MVC入门 —— 跟开涛学SpringMVC
- datagrid
- 曾经成功的敏捷团队为什么失败?
- c语言之正确使用const
- vc编译器选项
- [leetcode 77] Combinations
- OpenCV图像匹配算法之surf
- 概要设计文档编写规范
- 按拼音重复数匹配夫妻相
- p(a|b)=p(ab)/p(b)为什么?
- 五个步骤告诉你如何开发Web应用程序
- 天声人語 20150109
- 黑马程序员-IOS学习笔记-UITableView、UITableViewCell、UITableViewController
- APP手机客户端开发