Can someone please explain this editorial solution?

programming
Tags: #<Tag:0x00007f241e314db0>

#1

I am not getting it how did they solve it? I want to know the thinking process and some bit of explanation!


#2

Check the explanation here: Swap characters in a string