```
import copy
class Solution(object):
def __init__(self):
self.res = []
def rec(self, nums, i, n):
if i==n :
if not(copy.copy(nums) == self.res):
self.res.append(copy.copy(nums))
return
j = i
while(j < n):
aux = nums[j]
nums[j] = nums[i]
nums[i] = aux
self.rec(nums, i+1, n)
aux = nums[j]
nums[j] = nums[i]
nums[i] = aux
j = j + 1
def permute(self, nums):
res = []
self.rec(nums, 0, len(nums))
return self.res
```