how do we take input in this question.
Input taken in ques
@Zainul17192 Bro this is the whole logic, with input and removing cycle.
Set map = new HashSet();
int inp = scn.nextInt();
for (; inp > -1;) {
if(!map.contains(inp)) {
list.addLast(inp);
map.add(inp);
} else {
list.tail = null;
}
inp = scn.nextInt();
}
See There is a cycle for sure in this question as mentioned and cycle can only start with a tail.
Now do one thing dry run it with sample ya will get it!
Also bro if ya query is clear mark it resolved and rate full!
Happy coding!