```
class Solution:
# @param num, a list of integer
# @return a list of lists of integers
def permute(self, num):
'''
Don't consider duplicates.
If len(num) < 1, return [[]].
Insert each new value into all possible interspaces,
which there are n+1 of them if there have been n characters already.
'''
results = [[]]
for x in num:
results = [r[:i] + [x] + r[i:] for r in results for i in range(len(r)+1)]
return results
```