https://leetcode-cn.com/problems/reverse-linked-list/
class Solution: def reverseList(self, head: ListNode) -> ListNode: if not head or not head.next:return head p=self.reverseList(head.next) head.next.next=head head.next=None return p
class Solution: def reverseList(self, head: ListNode) -> ListNode: pre=None while head: end=head.next head.next=pre pre=head return pre