Write a function detectAndRemoveLoop() that checks whether a given Linked List contains a loop and if the loop is present then removes the loop and returns true. If the list doesn’t contain a loop then it returns false.
The below diagram shows a linked list with a loop. detectAndRemoveLoop() must change the below list to 1->2->3->4->5->NULL.
Detect and Remove Loop in a Linked List : https://www.geeksforgeeks.org/detect-and-remove-loop-in-a-linked-list/