https://ide.geeksforgeeks.org/7aCoKxuht1-------------my code is not working what is the error in the code. I have tried dry running it but was not able to find the mistake
Circular linked list problem
@AbhishekAhlawat1102,
The size of your linked list is coming to be 1 for the sample test case.
You can follow this approach to create your linked list:
Form a linked list 1->2->3->4>5 then you see that 2 has already been visited , so connect the next of 5 to 2 (which has already been created). This way you have created the circular linked list . After that just detect the cycle, remove the cycle, print the new linked list.
Maintain a map or a visited array…whenever you see that a node is already visited, connect next of previous node to that node