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],
[2,1,1]
]
我觉得跟46题没有区别,说是unique不过上一题也是unique啊。所以用了同一个答案,果然AC了。
所以答案就不贴出来了,就贴一种更高效的算法。
public List<List<Integer>> permuteUnique1(int[] nums) {
ArrayList<List<Integer>> results = new ArrayList<List<Integer>>();
if (nums == null) {
return results;
}
if (nums.length ==