this is my code for circular linked list challenge –https://ide.codingblocks.com/s/328343.
Cannot understand the error
First you have to input list in the given format and create a cycle from where the values start repeating. And then apply your cycle function on it.
Use the following code segment to input the cyclic linked list -
void buildList(node*&head)
{
int x;
cin>>x;
map<int,int> a;
while((x != -1) && (!a[x]))
{
a[x]++;
insertAtTail(head, x);
cin>>x;
}
if(x==-1)
return;
node*last = head;
while(last->next!=NULL)
last = last->next;
node*temp = head;
while(temp->data != x)
temp = temp->next;
last->next = temp;
while(x!=-1)
cin>>x;
}