1class Solution:2def swapPairs(self, head: Optional[ListNode]) -> Optional[ListNode]:34if not head or not head.next:5return head67dummy = ListNode(0)8dummy.next = head9curr = dummy1011while curr.next and curr.next.next:12first = curr.next13second = curr.next.next14curr.next = second15first.next = second.next16second.next = first17curr = curr.next.next1819return dummy.next