Detect and Remove Loop in a Linked List

1.5

4 votes
Problem

Write a function detectAndRemoveLoop() that checks whether a given Linked List contains loop and if loop is present then removes the loop and returns true. If the list doesn’t contain loop then it returns false. Below diagram shows a linked list with a loop.

                    

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?