Swap-nodes-in-pairs
![](https://www.5288z.com/wp-content/uploads/2020/05/swap-node-in-paris-1.png)
def swapInPairs(self, head):
pre, pre.next = self, head
while pre.next and pre.next.next:
a = pre.next
b = a.next
pre.next, b.next, a.next = b, a, b.next
pre = a
return self.next
detail setp is below the picture:
![](https://www.5288z.com/wp-content/uploads/2020/05/swap-node-in-pairs-2.png)