class Solution:
def reverse(self, head, pre = None):
while head:
head.next, head, pre = pre, head.next, head
return pre
输出:
A.next=null head=B pre=A
B.next=A head=C pre=B
C.next=B head=NULL pre=C
只有加粗数据保留,最后只返回C,C.next=B,B.next=A
翻转链表Python
最新推荐文章于 2024-12-07 20:36:26 发布
