Circular linked list problem

can you please explain me how to take input.

you can use set or any other ds like hashmap

using Set

int main(){
    node*head=NULL;
	int arr[10000]={};
	int cnt=0;
	int x;cin>>x;
	set<int>s;
	int cycle=-1;
	while(x!=-1){
		arr[cnt]=x;
		cnt++;
		s.insert(x);
		if(s.size()!=cnt){
			cnt--;
			 cycle=x;
			 break;
		}
		cin>>x;
	}
	for(int i=cnt-1;i>=0;i--){
		head=insertatbeg(arr[i],head);
	}
	// Print(head);
	makecycle(cycle,head);
    // cout<<detectCycle(head)<<endl;
    BreakCycle(head);
    Print(head);
	return 0;
}

this is main() function only
 now you have to make functions used in main()

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.