Changes need to do in detectcycle block?
your code is not according to question’s input
you are inserting the all elements till -1 which is not correct
you can use Reference Code
can you please write the steps we are following in breaking of cycle
this is the correct code
i have also update the above link as well
steps followed are simple same as floyd’s algorithms
-
take two pointers fast and slow move both accordingly
-
if they meet cycle present otherwise not
-
now point slow to head and fast to one step ahead
and move both single step
where fast->next==slow->next cycle is present at that point
so just do fast->next=NULL;
thank you so much man
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.