(self, head)
| 32 | return head |
| 33 | # recursion |
| 34 | def swapPairs2(self, head): |
| 35 | if not head or not head.next: |
| 36 | return head |
| 37 | |
| 38 | first, second = head, head.next |
| 39 | third = second.next |
| 40 | head = second |
| 41 | second.next = first |
| 42 | first.next = self.swapPairs(third) |
| 43 | return head |