用递归的方式解决排列组合问题
def zuhe(ss,res,path):
if ss == '':
res.append(path)
else:
for i in range(len(ss)):
zuhe(ss[:i]+ss[i+1:],res,path+ss[i])
剑指offer中——字符串排序问题,代码如下:

用递归的方式解决排列组合问题
def zuhe(ss,res,path):
if ss == '':
res.append(path)
else:
for i in range(len(ss)):
zuhe(ss[:i]+ss[i+1:],res,path+ss[i])
剑指offer中——字符串排序问题,代码如下:
本文标题:Python实现字符串排序(包含了排列组合问题)
本文链接:https://www.haomeiwen.com/subject/svgmdctx.html
网友评论