store all unique characters of current word in key
for ( int j = 0 ; j < str . length ( ) ; j ++ ) visited [ str [ j ] - ' a ' ] = true ; string key = " " ; for ( int j = 0 ; j < MAX_CHAR ; j ++ ) if ( visited [ j ] ) key = key + ( char ) ( ' a ' + j ) ; return key ; }