题目描述
输入一个链表,反转链表后,输出新链表的表头。
class Solution: # 返回ListNode def ReverseList(self, pHead): # write code here nextNode=None p=pHead while pHead is not None: pHead=pHead.next p.next=nextNode nextNode=p p=pHead return nextNode
本文共 361 字,大约阅读时间需要 1 分钟。
class Solution: # 返回ListNode def ReverseList(self, pHead): # write code here nextNode=None p=pHead while pHead is not None: pHead=pHead.next p.next=nextNode nextNode=p p=pHead return nextNode
转载于:https://www.cnblogs.com/zhaiyansheng/p/10414807.html