diff --git a/Week_01/id_19/24.py b/Week_01/id_19/24.py new file mode 100644 index 00000000..ccac0597 --- /dev/null +++ b/Week_01/id_19/24.py @@ -0,0 +1,11 @@ + +class Solution: + def swapPairs(self, head): + dummy = pre = ListNode(0) + pre.next = head + while pre.next and pre.next.next: + a = pre.next + b = a.next + pre.next, a.next, b.next = b, b.next, a + pre = a + return dummy.next