Swap with the next character and revert the changes . As explained above , swapping with previous is is not needed as it anyways happens for next character .
string [ index ] , string [ index + 1 ] = string [ index + 1 ] , string [ index ] NEW_LINE findPermutations ( string , index + 2 , n ) NEW_LINE string [ index ] , string [ index + 1 ] = string [ index + 1 ] , string [ index ] NEW_LINE