Proceed further for str [ i ] only if it doesn 't match with any of  the characters after str[index]
check = shouldSwap ( string , index , i ) NEW_LINE if check : NEW_LINE INDENT string [ index ] , string [ i ] = string [ i ] , string [ index ] NEW_LINE findPermutations ( string , index + 1 , n ) NEW_LINE string [ index ] , string [ i ] = string [ i ] , string [ index ] NEW_LINE DEDENT