[leetcode] Permutations II
来源:互联网 发布:淘宝怎么把好评转差评 编辑:程序博客网 时间:2024/05/14 02:25
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,[1,1,2]
have the following unique permutations:[1,1,2]
, [1,2,1]
, and [2,1,1]
.
class Solution {public: vector<vector<int> > permute(vector<int> &num) { // Start typing your C/C++ solution below // DO NOT write int main() function set<vector<int> >ret; int n=num.size(); _permute(num,n,n-1,ret); return vector<vector<int> >(ret.begin(),ret.end()); } void _permute(vector<int>& array,int n,int depth,vector<vector<int> >&ret){ if(depth==0){ ret.insert(array); return; } for(int i=0 ; i<=depth ; i++){ swap(array[i],array[depth]); _permute(array,n,depth-1,ret); swap(array[i],array[depth]); } return; }};
- 【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
- 软件测试(一)
- Class ThreadLocal<T>
- Centos6.4下安装Codeblocks12.11
- <c:foreach> 标签 varStatus属性的含义
- C++ 标准输出如何控制小数点后位数
- [leetcode] Permutations II
- VS2010使用GooglTest,GoogleMock
- 为什么要遵循统一的函数连接规范?什么事连接规范
- SMS Call---发送短信和打电话的方法
- NWChem 6.1.1 CCSD(T) parallel running
- Centos6.4下安装Boost1.51
- hdu 1203 I NEED A OFFER!
- Centos下安装Log4cxx
- HTML入门教程 - 3.页面标题(Titles of each pages)