剑指offer-二叉搜索树与双向链表(python)

抄的抄的抄的!!!我是实在不会啊,最后不懂为什么要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)))
            
发布了69 篇原创文章 · 获赞 46 · 访问量 5261

猜你喜欢

转载自blog.csdn.net/qq_42738654/article/details/104286785