leetcode 45: Permutations
来源:互联网 发布:美国EPO网络 编辑:程序博客网 时间:2024/05/15 12:27
Given a collection of numbers, return all possible permutations.
For example,[1,2,3]
have the following permutations:[1,2,3]
, [1,3,2]
, [2,1,3]
, [2,3,1]
, [3,1,2]
, and [3,2,1]
.
class Solution {public: vector<vector<int> > permute(vector<int> &num) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<vector<int> > rel; int level = 0; permuteRec( rel, num, level); return rel; } private: void permuteRec( vector<vector<int> > & rel, vector<int> &num, int level) { if( level == num.size() ) { rel.push_back( num ); return; } for( int i=level; i<num.size();i++){ if( i != level) { swap(num[i], num[level]); } permuteRec( rel, num, level+1); if( i != level) { swap( num[i], num[level]); } } } };
- leetcode 45: Permutations
- LeetCode 45 Permutations
- 【LeetCode】Permutations && Permutations II
- leetcode: Permutations/Permutations II
- leetcode Permutations & Permutations II
- [Leetcode]Permutations && Permutations II
- LeetCode: Permutations
- LeetCode: Permutations
- [Leetcode] Permutations
- [LeetCode] Permutations
- Leetcode: Permutations
- [Leetcode] Permutations
- [Leetcode] Permutations
- [LeetCode]Permutations
- LeetCode-Permutations
- [leetcode] permutations
- LeetCode - Permutations
- Leetcode: Permutations
- Javascript URL编码方法的比较
- ASP.NET动态设置css
- 时间、延迟及延缓操作
- win2008下解决支付宝密码不能输入的方法 2009
- 我的软件工程之路(五)—四个月总结
- leetcode 45: Permutations
- [程序猿感悟] 程序员感悟——路该怎么走
- 如何设计一款好玩的网络游戏
- list转数组类型
- java的图片的切割
- 推荐一款 chrome SSH 插件 - Secure Shell
- 检测主板的问题
- MATLAB产生三角波
- 封装json数据 需要导入的jar包