# -*- 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 not pHead:
return None
cur=pHead
pre=None
while cur:
tmp=cur.next
cur.next=pre
pre=cur
cur=tmp
return pre
剑指offer-反转链表(python)
最新推荐文章于 2021-11-05 10:53:13 发布