Python 代码
class Solution:
def permutation(self, nums):
self.res = []
self.dfs(nums,0)
return self.res
def dfs(self,nums,pos):
if pos > len(nums) - 1:
if nums[:] not in self.res:
self.res.append(nums[:])
return
for i in range(pos,len(nums)):
nums[pos],nums[i] = nums[i],nums[pos]
self.dfs(nums,pos + 1)
nums[pos],nums[i] = nums[i],nums[pos]