###### leetcode Permutations II

public class Solution {
public List<List<Integer>> permuteUnique(int[] nums) {
Arrays.sort(nums);
ArrayList<Integer> temp=new ArrayList<Integer>(nums.length);
for(int i=0;i<nums.length;i++)
{
}

boolean haveNext=true;
while(haveNext)
{
haveNext=false;
int i=temp.size()-1;
while(i>=1&&temp.get(i-1)>=temp.get(i))
{
i--;
}
if(i!=0)
{
haveNext=true;
int swapIndex=i-1;
int key=temp.get(swapIndex);
int k=temp.size()-1;
while(k>i&&temp.get(k)<=key)
{
k--;
}

int middletemp=temp.get(swapIndex);
temp.set(swapIndex, temp.get(k));
temp.set(k,middletemp);

reverse(temp,swapIndex+1,temp.size()-1);
}
}
return result;

}

public void reverse(ArrayList<Integer> tar,int start,int end)
{
int temp;
while(start<end)
{
temp=tar.get(start);
tar.set(start, tar.get(end));
tar.set(end,temp);
start++;
end--;
}
}

public List<Integer> getCopy(List<Integer> ori)
{
List<Integer> result=new ArrayList<Integer>();
return result;
}
}

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

2016-06-16 16:24:48

#### Permutations II -- LeetCode

2014-03-20 01:04:36

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

2016-03-01 10:17:28

#### Leetcode 47. Permutations II

2016-03-28 21:46:07

#### [LeetCode]47.Permutations II

2015-01-19 12:21:00

#### Leetcode Problem.47—Permutations II C++实现

2015-06-05 13:09:53

#### LeetCode Permutations I && II

2013-12-10 07:47:40

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

2017-10-03 11:15:45

#### [LeetCode][Java] Permutations II

2015-07-14 11:56:32

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

2017-06-29 16:21:55

## 不良信息举报

leetcode Permutations II