Leetcode Permutations
来源:互联网 发布:安禄山 杨贵妃 知乎 编辑:程序博客网 时间:2024/06/03 22:04
题意:生成排列数。
思路:DFS。
class Solution {public: vector <vector<int> > re; vector<vector<int>> permute(vector<int>& nums) { dfs(nums, 0); return re; } int dfs(vector<int> sub, int k) { if(sub.size() - 1 == k) { re.push_back(sub); return 0; } vector<int> temp; int ch; for(int i = k; i < sub.size(); ++ i) { temp = sub; ch = temp[k]; temp[k] = temp[i]; temp[i] = ch; dfs(temp, k + 1); } return 0; }};
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
- 在app的gradle中添加不审核图片类型
- PL/SQL Developer 导入或者导出CSV文件
- Java运行时常量池与final修饰符的关系
- 大小端模式
- USB固件开发
- Leetcode Permutations
- Excel中如何不让身份证号码按科学计数法显示
- 这教育,毁人不倦
- sencha touch在android物理后退键解决方法
- hdu 1728:逃离迷宫
- 1393-二分图多重匹配问题
- Java.lang.LinkageError
- python学习笔记:字典嵌套,将字典作为VALUE加入字典中
- Leetcode Delete Node in a Linked List