【Leetcode】之Permutations II

来源:互联网 发布:sql查询分析器下载 编辑:程序博客网 时间:2024/05/01 12:37

一.问题描述

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.csdn.net/a83610312/article/details/9632497

0 0
原创粉丝点击