【剑指offer】面试题28:字符串的排列

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]
			

你可能感兴趣的:(Algorithm,python,面试题)