Circular linked list

I. Am unable to take input in the circular linked list some one plzz help me how to take input in the cyclic form

@Nilesh-Kumar-1173882276149322 Hi bro, input to stub mein lia hi hai, bs there you have to modify it to accommodate logic.

  • Given in question, numbers are distinct just start to repeat if there is any cycle.
  • Cycle can only start from tail.

So if you encounter a number again which was previously input that means cycle has started so at that point break the cycle.

Use set as it only contains distinct numbers.

Here is the whole logic

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();
}

Number repeat hua then cycle has started break it.

If you have query ask me or resolve the doubt bro!

I am not able to code can u plzz send your code

Bro this is the code, this the logic which you have to write in main, there must be an inbuild linkedlist right?

Nope bro their is no inbuild linkedlist plzz see the que

@Nilesh-Kumar-1173882276149322 Okay buddy here is my code but do code it again.

And resolve the doubt bro!