"""
设计:Python程序设计
作者:初学者
日期:2022年 03月 22日
"""
class Solution:
def permutation(self, nums):
def _permute(result, temp, nums):
if nums == []:
result += [temp]
else:
for i in range(len(nums)):
if i > 0 and nums[i] == nums[i - 1]:
continue
_permute(result, temp + [nums[i]], nums[:i] + nums[i + 1:])
if nums is None:
return []
if len(nums) == 0:
return [[]]
result = []
_permute(result, [], sorted(nums))
return result
if __name__ == '__main__':
s = Solution()
nums = [1, 2, 2]
result = s.permutation(nums)
print("输入:", nums)
print("输出:", result, end=" ")