def Permutation(data, i):
if len( data ) == 0:
return
# i stand for the start of first part
for i in range(i, len( data ) - 1):
# j stand for the start of second part
for j in range(i + 1, len( data )):
# swap the items of two part
data[i], data[j] = data[j], data[i]
Permutation(data, i + 1)
# for next swap, we should recorver the last swap
data[i], data[j] = data[j], data[i]
【剑指offer】面试题28:字符串的排列
最新推荐文章于 2022-05-18 16:34:45 发布