思路:顺序遍历字符串,取当前字符串与除去当前字符串的全排列中的元素组成新的组合作为结果

注意:递归出口,当字符串为1时,返回当前字符串

class Solution:
    def Permutation(self , str: str) -> List[str]:
        
        if len(str) <= 1:
            return str
        
        result = []
        for i in range(len(str)):
            s1 = str[i]
            for s2 in self.Permutation(str[:i]+str[i+1:]):
                s = s1 + s2
                if s not in result:
                    result.append(s)
        return result