Stuck in TLE, Python

  • 0

    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.

    class Solution(object):
    def swapPairs(self, head):
    :type head: ListNode
    :rtype: ListNode
    if not head or not
    return head

        n1, n2 =, head
        head =
        while and
            temp =
   = n1
   = temp
            n1 = temp
            n2 = = n1 = None
        return head


Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.