class Solution: def ReverseList(self, head: ListNode) -> ListNode: pre = None while head: head.next, pre, head = pre, head, head.next return pre