Removing a loop in a singly linked list
Problem:
Remove a loop from a singly linked list if the list has a loop.
Example
For example, 1->2->3->4->1 (4 points to the head node 1) should become 1->2->3->4 while 1->2->3->4 should stay the same 1->2->3->4.
Solution The problem has 3 steps :
Detect if there is a loop in the list (already solved here) Identify the start of the loop (already discussed here) Delete the loop, which we will discuss here.
[Read More]