Circular linked list doubt

here i don’t get how to take this ll as input having a cycle i know how to detect a cycle but for that we need address of head

here what iam thinking to make a map and store frequency of every input and then when fequency of input start incresing from 1 to 2

then i stop putting my input into map
and finally then print my map
is this is the way of doing this question

no this is not the way to do this

  1. first make cycle in linked list using given input
  2. and then detect and remove cycle
  3. at last print the new linked list(without cycle)

for step 1 use can either use map or 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;
}

now implement function used in main()

i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course

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.