Remove loop from list

Remove loop from list

Algorithm:

  • Use Runner algorithm to detect loop
    • In Runner algorithm we have two pointer slowPtr and fastPtr
  • Now move slow pointer to head of list and
  • Iterate one by one node from head by slowPtr and from circle by fastPtr
  • Both will meet starting starting point circle.

Latest Source Code:
Github: ListLoopRemover.java


Output:

1 2 3 4 5 6 7 8 9 10 11 
Author: Hrishikesh Mishra