Proceed further for str [ i ] only if it doesn 't match with any of the characters  after str[index]
bool check = shouldSwap ( str , index , i ) ; if ( check ) { swap ( str [ index ] , str [ i ] ) ; findPermutations ( str , index + 1 , n ) ; swap ( str [ index ] , str [ i ] ) ; } } }