# -*- coding:utf-8 -*-
class Solution:
def Permutation(self, ss):
# write code here
if not ss:
return []
ss=list(ss)
l=[]
stt=''
self.dp(ss,l,stt)
return l
def dp(self,ss,l,stt):
if not ss and stt and stt not in l:
l.append(stt)
return
for s in ss:
ll=ss[:]
ll.remove(s)
stt+=s
self.dp(ll,l,stt)
stt=stt[:-1]
我的算法之路48--字符串的排列
最新推荐文章于 2023-03-30 21:34:18 发布