SWAPGAME LOGIC

Most of the top submissions for the SWAPGAME problem used an approach different than the one discussed in editorial and is more efficient, can someone explain the algo behind the approach and why it works??

@harsha_0621w I added my explanation to the editorial thread