```
class Solution(object):
def permute(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
answer = []
rec = [0 for i in xrange(len(nums))]
def dfs(ans):
if len(ans) == len(nums):
answer.append(ans[:])
return
for i in xrange(len(nums)):
if rec[i] != 1:
rec[i] = 1
dfs(ans + [nums[i]])
rec[i] = 0
dfs([])
return answer
```