bool floyedDetectionLoop (node* head) { if (head == NULL) { return false; } node* fast = head; node* slow = head; while (fast != NULL && slow != NULL) { fast = fast -> next; if (fast -> next == NULL) { fast = fast -> next; } slow = slow -> next; if (fast == slow) { return true; } } return false; }