Accepted O(1) solution (joking)

  • 0

    After figuring out the biggest length is 8030, I use the following code to get accepted

    bool hasCycle(ListNode *head) {
        for (int i = 0; i < 8030 && head; ++i) {
            head = head->next;
        return !!head;

Log in to reply

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