Break the linked List from middle in O(n) time Using fast and slow pointers

PHOTO EMBED

Sat May 27 2023 13:12:19 GMT+0000 (Coordinated Universal Time)

Saved by @DxBros #c++ #halve_the_ll

        if(!head || head->next  == NULL)
            return head;
        Node* fast = head->next->next,*slow = head;
        while(fast->next && fast->next->next){
            fast = fast->next->next;
            slow = slow->next;
        }
        if(fast != NULL)
            slow = slow->next;
        Node* head2 = reverse(slow->next);
        slow->next =  NULL;
content_copyCOPY

https://practice.geeksforgeeks.org/problems/modify-linked-list-1-0546/1