Python 线性表就地逆置算法实现与代码解析
def reverse_sequence_list(lst):
'首尾指针分别指向线性表的首尾元素'
start = 0
end = len(lst) - 1
while start < end:
'将首尾元素交换位置'
lst[start], lst[end] = lst[end], lst[start]
'首指针向后移动一位'
start += 1
'尾指针向前移动一位'
end -= 1
原文地址: http://www.cveoy.top/t/topic/bk1v 著作权归作者所有。请勿转载和采集!