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<

该博客介绍了LeetCode第47题的解决方案,即如何从包含重复元素的集合中找到所有唯一的排列。作者指出此题与第46题相似,并分享了一种更高效的算法来解决这一问题。
订阅专栏 解锁全文
566

被折叠的 条评论
为什么被折叠?



