Https://ide.codingblocks.com/s/434481

Pls point out the mistake in my code.It’s giving wrong input.

You don’t have to swap. Here it’s working now https://ide.codingblocks.com/s/434566

Thanks but what was going wrong in swapping?

You need to maintain it in reverse order na. By swapping you aren’t reversing it, Dry run the code once.

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.