Min Palindromic Swaps!

Please help me with this problem , Logic seems to be correct . Its failing for two /four hidden test case .

thanks in advance !

https://www.codechef.com/viewsolution/30007610

I think so, you are not checking case when it is possible that i+1 is equal to j or vise-versa at that point you can’t because you are comparing the same position value and swapping.
if(i+1==j){
flag=1;
break;
}
I hope I made it clear.I did this change in your code it run.You may check.

1 Like

Thanks for pointing it out. :slight_smile: