error?
why is it giving wrong output
Circular linked list
Hello @krishnakumarkrish,
The logic you have used for detecting and breaking the loop would not work for the linked list you have created.
The linked list you have created is linear and contains no loop.
Solution:
Just look for the node when the elements start repeating and break it from there.
OR
Create the loop in the list.
Hope this would help.