Can anyone explain to me i am getting a Time Limit Exceeded (TLE) error on the below code?
And i am sure its not stuck in the while loop.
def swapPairs(self, head):
:type head: ListNode
if not head or not head.next:
n1, n2 = head.next, head head = head.next while n2.next and n2.next.next: temp = n2.next n2.next = n1 n1.next = temp n1 = temp n2 = temp.next n2.next = n1 n1.next = None return head