赞
踩
题目:47. 全排列 II
链接:https://leetcode-cn.com/problems/permutations-ii/description/
给定一个list(可能含有重复元素),返回其不重复的全排列。例如:
输入: [1,1,2] 输出: [ [1,1,2], [1,2,1], [2,1,1] ]
python:
- import itertools
- class Solution:
- def permuteUnique(self, nums):
- """
- :type nums: List[int]
- :rtype: List[List[int]]
- """
- return list(set(list(itertools.permutations(nums))))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。