Please tell the error in my code

take this example
1 2 3 4 5 1 1 2 3 -1 (although what i am gonna explain will happen in all cases, circular or not)
it starts at 1;
iy = it++ this means, it goes to 2 and iy is assigned to 1
in the immediate next iteration. iy will come to 2 and iy is also there. so if condition is satisfied and the rest of the list is erased
if you want to do it like this, u need to keep track of the numbers. use an unordered_map
and at each step check whether the element is present already in the map or not, if not then push the element in the list and in the map otherwise do not push it and just continue the loop

1 Like

Ok will see to it ,
thanks

hey, if your doubt is solved, please mark it as resolved, @Ramitgoel