leetcode Permutations II
来源:互联网 发布:乔丹生涯数据总汇 编辑:程序博客网 时间:2024/06/16 21:18
参考博客
http://www.cnblogs.com/tenosdoit/p/3662644.html
代码
class Solution {public: vector<vector<int> > permuteUnique(vector<int> &num) { vector<vector<int> > result; if(num.size()==0) return result; sort(num.begin(), num.end()); result.push_back(num); while(next_permuteUnique(num)) result.push_back(num); return result; } bool next_permuteUnique(vector<int> &num) { if(num.size()==1) return false; for(int i = num.size()-2, ii = num.size()-1; i >= 0; --i, --ii) { if(num[i] < num[ii]) { int j = num.size()-1; while(num[j]<=num[i]) --j; swap(num[i], num[j]); reverse(num.begin()+ii, num.end()); return true; } } return false; } };
0 0
- 【LeetCode】Permutations && Permutations II
- leetcode: Permutations/Permutations II
- leetcode Permutations & Permutations II
- [Leetcode]Permutations && Permutations II
- Leetcode: Permutations and Permutations II
- leetcode-permutations and permutations II
- Leetcode:Permutations与Permutations II
- LeetCode: Permutations II
- LeetCode Permutations II
- LeetCode: Permutations II
- [Leetcode] Permutations II
- [LeetCode] Permutations II
- [Leetcode] Permutations II
- leetcode Permutations II
- [LeetCode]Permutations II
- leetcode - Permutations II
- LeetCode-Permutations II
- [leetcode] Permutations II
- 第一次作业,求过
- coredata模糊查询
- 并查集+向量偏移
- 求分段函数的值
- 深入理解SELinux/SEAndroid(最后部分)
- leetcode Permutations II
- latex 改变字体颜色
- 可爱的360面试官
- 判断iframe是否加载完成的完美方法
- android 通过占位符来动态获得字符串资源
- 网络通信框架Volley使用详细说明
- 1.3 两条直线是否相交
- stdarg.h
- Linux - SVN下载项目