Circular linked list problem

how to take input? i mean how to create the linked list on which we have to operate

Maintain a map and keep adding elements in the end of our linked list if they are unique. Take these inputs till -1 is encountered or an element which is already present in our linked list.
In the latter case, traverse the linked list and find that node. Then attach the linked list’s last node->next to that found node.

you are telling me to first add all elements in map.then create a linked list and search for the repeated node then find the last node create a circular link…then write program to remove the link…dat doesnt makes sense?if it has to be done with maps i can simple keep adding the elements in map and print them
i want to do it with linked list only…

Add elements in the map and linked list simultaneously.
Map is used only to check for repetition.
For example consider the sample test case given - 1 2 3 4 5 2 3 -1
We add elements in our map and at the same time keep creating our linked list till 5. But when 2 comes, which is already present in our map, we attach 5->next = 2 which gives us our required circular linked list.

@Krishna-Singh-2678805765519156 Please mark your doubt as resolved if you are satisfied

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.