Problem with the code, please explain?

I think your logic is wrong here. When the element from the upper array is same as ideal array, remove it. else you pop it, and put it at the end. What you are doing is you are popping and putting it back but then you are removing all of the characters in between. Please notice that the order in which elements are finally removed from the array has to be in ideal order.

so please send me the rectified code

I am not allowed to send you entire code. I gave you a hint, try out this logic and if it still fails I can correct your code

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.