Getting wrong output

my code is passing all the test cases but for the input of (xxax) the output should be (axxx) but my code is giving me output (xaxx). inshort my code is not 100% correct as it is passing all the test cases. please tell me why this is happening and how to correct it.

hello @shivamgoel150
do a dry run on the same test case.
that will help u in getting ur mistake

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.