Remove a cycle in Linked lIst

https://ide.codingblocks.com/s/43157

You haven’t created a loop .Your sample test case is 1 2 3 4 5 2 3 -1 ,
which creates a 2 and 3 as new node and not the previous one, to do so you have to give them same address, i.e you can do so by head->next->next->next->next=head->next.
Now try the question.

can you elaborate?

I guess this is the reason no cycle was created.

How do we create a cycle of linked list using set of integers? Implement it pls.

You need to share the same address for two nodes.
Like in your case 5 is pointing to 2 and 2 has its own address, so 5 and 2 are sharing the same address. So you have to make sure that there is atleast two nodes having the same address for creating one or more loops.
For implementation purpose:
Just by a simple while loop, traverse till the node you want to go and give it the address of some other node
eg: head->next->next=head. By this 3rd and 1st node have same address.