Python code shows TLE, but locally runs correct


  • 0
    S

    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 curr.next:
                if curr.next == head:
                    return curr
                curr = curr.next
            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.