[leetcode] Permutations
来源:互联网 发布:七天爱上你在哪网络看 编辑:程序博客网 时间:2024/05/22 08:01
Permutations
思路:交换+DFS
class Solution { vector<vector<int> > res; int length; public: vector<vector<int> > permute(vector<int> &num) { length=num.size();//有length个数 res.clear(); perm(num,0); return res; } void perm(vector<int> &num,int i){ if (i==length) { res.push_back(num); } for (int j=i; j<length; j++) { swap(num[i], num[j]); perm(num, i+1); swap(num[j], num[i]); } }};
Reference:
permutations的讨论
0 0
- 【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
- 【leetcode】Permutations
- 【LeetCode】Permutations
- 线性表
- 交通灯管理系统
- mysql初次探索
- jrtplib3.9.1 example4
- UI分页
- [leetcode] Permutations
- jQuery Mobile页面跳转后未加载外部JS
- 虚拟机磁盘空间扩容
- 在Eclipse中配置tomcat
- 第十四周工作周报--------龙行
- java线程模型Master-Worker
- http://blog.sina.com.cn/s/blog_458f3c010100n4st.html
- NSTimer 定时器
- 黑马程序员---IO包中的其它类