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

 

相关文章:

  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2022-12-23
  • 2021-06-03
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2021-12-21
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
相关资源
相似解决方案