I am getting tle error

this function is
bool floydCycleRemoval(Node head)
{
Node
fast=head->next;
Node* slow=head;
while(fast!=NULL or fast!=NULL){
fast=fast->next->next;
slow=slow->next;
if(fast==slow){
slow=head;
while(fast->next!=slow->next){
fast=fast->next;
slow=slow->next;
}
fast->next=NULL;
return true;
}
}
return false;
}

modified code

bool floydCycleRemoval(Node* head)
{
    if(head==NULL or head->next==NULL)return false;
    Node* fast = head->next;
    Node* slow = head;
    while (fast != NULL and fast->next != NULL) {
        fast = fast->next->next;
        slow = slow->next;
        if (fast == slow) {
            slow = head;
            fast=fast->next;
            while (fast->next != slow->next) {
                fast = fast->next;
                slow = slow->next;
            }
            fast->next = NULL;
            return true;
        }
    }
    return false;
}