classSolution:defpermuteUnique(self,nums: List[int]) -> List[List[int]]: res = []defbacktrack(curr,counter):iflen(curr)==len(nums): res.append(list(curr))returnfor num in counter:if counter[num]>0: counter[num]-=1 curr.append(num)backtrack(curr, counter) counter[num]+=1 curr.pop()backtrack([], Counter(nums))return res