抄的抄的抄的!!!我是实在不会啊,最后不懂为什么要sorted,
# -*- coding:utf-8 -*-
class Solution:
def Permutation(self, ss):
# write code here
sets=set(ss)
res=[]
list_s=list(ss)
if not ss:
return []
elif len(sets) == 1:
return [ss]
for i in sets:
g=list_s[:]
g.remove(i)
res+=[i+j for j in self.Permutation(''.join(g))]
return sorted(list(set(res)))