Please check the code
Hello @tharun,
The linked list you have formed is structurally linear.
There is no actual loop or cycle in it.
Thus, the fast and slow pointers will not work for the linked list you have created.
Solution:
- just look for the repeating element in your linked list and break it from there to remove cycle.
- to apply two pointers approach that you have written, create a cycle in your linked list.
You can refer to this code I have corrected earlier:
https://ide.codingblocks.com/s/221643
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.