How to take input in cycle

sir made function “detectCycle( )” (at time 3:14) in video so how to take cyclic input of LinkedList to check it’s working or not.

and check my code for removeCycle( ) ( in line 384 - 407 ) is it correct or not?

hi @mahroosanwar0901_2642b14836027bbf,
input will be taken u just need to write this function
correction :
u got the node which is making cycle now just go to the node before it and open the cycle

u can refer https://ide.codingblocks.com/s/659110

and there must be a question in assignment section u can try that to check, if not try submitting in leetcode or gfg

“input will be taken u just need to write this function” —> what function?

//this function will work?
node* take_input(){
int d;
cin >> d;
node*head = NULL;
while(d != -1){
insertAtHead(head, d);
cin >> d;
}
return head;
}

for example: In image 3 is connected to 3 elements (2 , 4, 7) so do we have to consider this in input function ; and HOW?

@mahroosanwar0901_2642b14836027bbf,
To remove cycle - u need to remove the 7->3 link here to open the cycle
and the input will be taken for this question and u just need to write the function to remove the node or detect the cycle, probably there wont be any question where you would be making this cyclic linked list

No that function wont work, and you dont even need that thing that will be given to you

okay thanks …

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.