# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return string字符串一维数组 # class Solution: def p(self,num, used, path, res): if len(path) == len(num): res.append(path[:]) return for i in range(len(num)): if i>0 and num[i-1] == num[i] and used[i-1] == 0: continue if used[i] == 1: continue path.append(num[i]) used[i] = 1 self.p(num, used, path, res) path.pop() used[i] = 0 def Permutation(self , str: str) -> List[str]: s = list(str) s.sort() str = ''.join(s) # write code here res = [] a = [] self.p(str, [0]*len(str), [],res) for i in res: a.append(''.join(i)) return a