void removeLoop(Node* head) {
// code here
Node* slow = head, *fast = head;
while(fast && fast->next) {
slow = slow->next;
fast = fast->next->next;
if(slow == fast) {
slow = head;
// check if fast and slow pointer at head node
if(fast == slow) {
while(fast->next != slow)
fast = fast->next;
}
else {
while(slow->next !=fast->next) {
slow = slow->next;
fast = fast->next;
}
}
fast->next = NULL;
}
}
}