# Permutations II 字符全排列 去除重复的

### Permutations II

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:
//先排序，以[1, 1, 2]，第一个1处理过以后，第二个1就可以跳掉了。
vector<vector<int>> permuteUnique(vector<int>& nums) {

int n=nums.size();
vector< vector<int> >res;
vector< int > path;

sort(nums.begin(),nums.end());
solve(res,nums,path,0,n);

return res;
}

void solve(vector< vector<int> > &res, vector<int> &nums,vector<int> &path, int index, int n)
{
if(index==n)
{
res.push_back(path);
return ;
}

for(int i=index;i<n;i++)
{
if(i>index && nums[i]==nums[index])//相等 不考虑
continue;
else
swap(nums[i],nums[index]);

path.push_back(nums[index]);
solve(res,nums,path,index+1,n);
path.pop_back();
}
sort(nums.begin()+index,nums.end());
}
};

#### [leetcode]47. Permutations II,python实现

2016-06-16 16:24:48

#### 【leetcode】【47】Permutations II

2016-03-01 10:17:28

#### leetcode - 47. Permutations II(全排列)

2017-06-29 16:21:55

#### Leetcode 47. Permutations II

2016-03-28 21:46:07

#### 一次搞懂全排列——LeetCode四道Permutations问题详解

2017-03-26 17:52:17

#### [Leetcode][python]Permutations/全排列

2017-10-03 11:15:45

#### ***[Lintcode]Permutations II 带重复元素的排列 递归/非递归解法

2016-11-08 16:11:50

#### leetcode 46,47. Permutations I/II 全排列问题 java

2016-04-19 23:00:36

#### leetcode46/47-Permutations I/II(全排列问题)

2016-04-28 23:26:35

#### leetcode 46. Permutations-全排列|回溯|递归|非递归

2016-05-29 22:15:10