Circular linklist

https://ide.codingblocks.com/s/57513 what wrong in this code please debug

Hi Neeraj, your buildlist function is not correct. You’re creating a linear singly linked list for the given input. That’s why your logic of detection and removal of loop is not working because a loop does not exist. You have to create a loop in linked list if a number appears again.
Example.
Screenshot%20(96)

So, you need to modify your buildlist function such like while adding a new node you first check if a node with same data already exists or not. If a node already exists having the same data as newNode then do it as lastNode->next = sameDataNode, otherwise do lastNode->next = newNode.