Find characters of s1 that are not present in s2 and append to result
for ( int i = 0 ; i < s1 . size ( ) ; i ++ ) { if ( m . find ( s1 [ i ] ) == m . end ( ) ) res += s1 [ i ] ; else m [ s1 [ i ] ] = 2 ; }