题目描述
输入一个链表,反转链表后,输出新链表的表头。
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
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