0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| def permuteUnique(self, nums: List[int]) -> List[List[int]]: result,path,used = [],[],[False for _ in nums] nums.sort() def sort_tree(nums,used): if len(path)==len(nums): result.append(path.copy()) for i in range(0,len(nums)): if used[i]==True: continue if i>0 and nums[i-1]==nums[i] and used[i-1]==False: continue used[i] = True path.append(nums[i]) sort_tree(nums,used) path.pop() used[i] = False return result return sort_tree(nums,used)
|