CIrcular Linked List

Question Link: https://hack.codingblocks.com/contests/c/511/471

My Solution Link : https://ide.codingblocks.com/s/37962

Please see the code and correct the remove loop function.

********************Please correct the code & comment where editing.

Your code is completely wrong.
For the input
1 2 3 4 5 2 3 -1
it gives the output
-1 3 2 5 4 3 2 1

But the correct output is
1 2 3 4 5

Your code is displaying only the reverse of the input.

Check your removeLoop function. It is not correct. Try to think of the logic again and then implement it…

Please check i have update the code but i have made some mistake in removeloop function. Please help me by correcting the code.

Share the link of your updated code.

I have edited the link above in the post

This is the same earlier code. You are supposed to save the code again after editing to reflect the changes.

The link is same as posted earlier. Save your code after making changes, then you’ll get new link, and share that here.

Hey Unique, in your code you have called this function " detectAndRemoveLoop(head); " in main(). but you haven’t written this function anywhere in your code.

sorry for that
I will write entire code for the same from starting.

okay cool :slight_smile:

I can’t write the code to remove cycle. Please help me by forwrding code so that i can take reference.:pensive:

You have the option of opening editorial now.
If you can’t think of some question, you can unlock its editorial.
You will not be awarded points for it, but you can learn from it.

For this question you can refer code as given by @sanjeetboora
as this is a doubt from a long time.
Try to take hint from the question and then attempt it yourself.

Hey Unique, you can refer this code circular linked list

https://ide.codingblocks.com/s/283008 please resolve the issue