```
class Solution:
# @param {integer[]} nums
# @return {integer[][]}
def permuteUnique(self, nums):
def replace(ls, integer):
lst = list(ls)
lst.remove(integer)
return lst
f = lambda s: [s] if (len(s) == 1) else [[x] + y for x in set(s) for y in f(replace(s, x))]
return f(nums)
```