题目描述
输入一个链表,反转链表后,输出链表的所有元素。
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# 返回ListNode
def ReverseList(self, pHead):
# write code here
temp = None
while pHead:
cur = pHead.next
pHead.next = temp
temp = pHead
pHead= cur
return temp
https://blog.csdn.net/songyunli1111/article/details/79416684