class Solution:
def swapPairs(self, head: ListNode) -> ListNode:
Head = ListNode(0)
Head.next = head
if not head or not head.next:
return head
pre, i ,j = Head, head, head.next
while i and j:
#交换
i.next = j.next
j.next = i
pre.next = j
#更新
pre = i
i = i.next
if i: #若i非空才有j
j = i.next
return Head.next