参考代码:
class Solution:
def permute(self, nums):
def _permute(result, temp, nums):
if nums == []:
result += [temp]
else:
for i in range(len(nums)):
_permute(result, temp + [nums[i]], nums[:i] + nums[i + 1:])
if nums is None:
return []
if nums is []:
return [[]]
result = []
_permute[result, [], sorted(nums)]
return result