📜  leetcode 206 python 代码示例

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

代码示例1
class Solution:
    def reverseList(self, head: ListNode) -> ListNode:
        if not head or not head.next:
            return head
        pre,tmp=None,None
        while(head):
            tmp=head.next
            head.next=pre
            pre=head
            head=tmp
        return pre