一.问题描述
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].
二.我的解题思路
最简单的思路就是在之前permutation的基础上,使用hash_map来记录每个出现过的排列。这样做比较简单,但是耗时比较大,leetcode上测试居然没有超时。。
比较好的解题思路参见 http://blog.youkuaiyun.com/a83610312/article/details/9632497
本文探讨了如何在存在重复元素的情况下,生成所有可能的唯一排列组合。通过使用hash_map来避免重复排列,提供了高效解决问题的方法。深入分析了算法逻辑与优化策略。
3144

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



