题解 | #反转链表#
反转链表
https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
class Solution:
def ReverseList(self , head: ListNode) -> ListNode:
# write code here
pre = None
cur = head
while cur != None:
temp = cur.next
# 反转
cur.next = pre
pre = cur
cur = temp
return pre