Python code shows TLE, but locally runs correct

  • 0

    my code shows TLE and this error message:

    Last executed input: [3,2,0,-4], tail connects to node index 1

    class Solution:
        # @param head, a ListNode
        # @return a boolean
        def detectCycle(self, head):
            curr = head
            while curr and
                if == head:
                    return curr
                curr =
            return None

    code runs fine on my machine. can anyone tell me what's wrong?

Log in to reply

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