day9-链表练习题力扣206

思路: 伪代码
while(head != null and head.next != null):
dnext = dummy.next
hnext = head.next
dummy.next = hnext
head.next = hnext.next
hnext.next = dnext
return dummy.next

Python代码
def reverseList(self, head: ListNode) -> ListNode:
dummy = ListNode()
dummy.next = head
while head != None and head.next != None:
dnext = dummy.next
hnext = head.next
dummy

day9-链表练习题力扣206最先出现在Python成神之路

版权声明:
作者:Zad
链接:https://www.techfm.club/p/10816.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>