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?