1class Solution:
2 def reverseList(self, head: ListNode) -> ListNode:
3 if not head or not head.next:
4 return head
5 pre,tmp=None,None
6 while(head):
7 tmp=head.next
8 head.next=pre
9 pre=head
10 head=tmp
11 return pre