text: All the characters are checked whether it 's either not replaced or replaced  by a similar character using a map.
code: Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( ! mp . ContainsKey ( s1 [ i ] - ' a ' ) ) { mp . Add ( s1 [ i ] - ' a ' , s2 [ i ] - ' a ' ) ; } else { if ( mp [ s1 [ i ] - ' a ' ] != s2 [ i ] - ' a ' ) return false ; } }