Python实现链表倒序(带头指针)
class ListNode(object): def __init__(self, x): self.val = x self.next = None def reverseList(self, head): if head == None or head.next == None: return head p = head.next while p.next: p1 = p.next p.next = head head, p = p, p1 p.next = head return p