def reverse(head):
if head == None or head.next == None:
return head
psuhead = ListNode(-1)
while head:
nexthead = head.next
head.next = psuhead.next
psuhead.next = head
head = nexthead
head = psuhead.next
del psuhead
return head
【剑指offer】Q16:翻转链表
最新推荐文章于 2021-08-25 17:32:12 发布