Getting error in circular LL problem

please check and where I am getting error in the folllowing code : https://ide.codingblocks.com/s/211158

Hello @abhinavakhil55,

The fast and slow pointers would not work in the linked you have created.
Reason:
The linked list is linear. There is no actual cycle in the linked list.

Solution:

  1. Either you can check for the element after which elements starts repeating in your linear linked list and remove the loop.

  2. You can create a loop while inserting elements in your linked list and then apply the logic of two pointers to detect and remove the loop.
    You can refer to this code i have corrected earlier:
    https://ide.codingblocks.com/s/161841

Hope, this would help.
Give a like if you are satisfied.

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.