问题:
题目来源:力扣(LeetCode)
难度:中等
分析:
回溯法+剪枝
相比于leetcode46.全排列,题目增加了重复元素的要求。在leetcode46.全排列的基础上加两行剪枝排除重复元素就可以。
为了排除重复元素,先进行一下排序。
解决方法:
1:回溯+剪枝
class Solution:
def permuteUnique(self, nums: List[int]) -> List[List[int]]:
if len(nums) == 0: