题目描述
输入一个链表,反转链表后,输出新链表的表头。
# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # 返回ListNode def ReverseList(self, pHead): # write code here if pHead==None: return None a=pHead b=pHead.next a.next=None while b : c=b.next b.next=a a=b b=c return a
原文地址:https://www.cnblogs.com/hit-joseph/p/9523224.html
时间: 2024-10-09 14:09:42