📅  最后修改于: 2022-03-11 14:45:36.590000             🧑  作者: Mango
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