📜  python反向链表——Python代码示例

📅  最后修改于: 2022-03-11 14:47:14.832000             🧑  作者: Mango

代码示例1
def reverseLinkedList(root):
    cur = root
    prev = None
    
    while cur:
        nxt = cur.next
        cur.next = prev
        prev = cur
        cur = nxt

    return prev