[LeetCode] Combinations
来源:互联网 发布:linux 解压zip 重命名 编辑:程序博客网 时间:2024/05/01 16:48
class Solution {public: vector<vector<int> > ret; vector<int> sln; void DFS(int n, int k, int m) { if (k == 0) { ret.push_back(sln); return; } if (m > n) return; DFS(n, k, m + 1); sln.push_back(m); DFS(n, k - 1, m + 1); sln.pop_back(); } vector<vector<int> > combine(int n, int k) { // Start typing your C/C++ solution below // DO NOT write int main() function ret.clear(); DFS(n, k, 1); return ret; }};
Small Case: 4ms
Large Case: 52ms
- LeetCode: Combinations
- LeetCode: Combinations
- LeetCode Combinations
- [Leetcode] Combinations
- [LeetCode] Combinations
- Leetcode: Combinations
- LeetCode Combinations
- [Leetcode] Combinations
- [Leetcode] Combinations
- [leetcode] Combinations
- [LeetCode]Combinations
- [leetcode]Combinations
- LeetCode-Combinations
- [leetcode] Combinations
- LeetCode - Combinations
- 【Leetcode】Combinations
- Leetcode: Combinations
- 【leetcode】Combinations
- YII 中使用Ueditor
- Android中的Audio播放:音量和远程播放控制
- Vim Essential Plugin: NERDTree
- 策略模式
- USACO:Prime Palindromes
- [LeetCode] Combinations
- Spring Blazeds integration
- Uva 10635 王子和公主(LCS转LIS+二分)
- c++中构造函数初始化的方法以及主要区别
- matlab变量及运算符
- vim插件cscope安装
- Core Java (二十三) 集(Set接口)
- 两军交锋 hdu2548 水题
- android的项目的目录结构