When we take inputs, after completion of cycle the same number then will be taken as a new node data and not as the previous address. So how is the cycle is even inserted.
How to insert cycle
@tishachhabra2702_8fc5a68a2e295e35 either you have to check every node previously added in linkedlist when you add a new node or you can use a hashmap to tell you that this data is already present. Latter case is preferred bcoz it minimises your time complexity.
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.