Iterate through the second string update char_count . If character is not found in char_count then increase count
for ( let i = 0 ; i < s2 . length ; i ++ ) { char_count [ s2 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] -- ; } for ( let i = 0 ; i < 26 ; ++ i ) { if ( char_count [ i ] != 0 ) { count += Math . abs ( char_count [ i ] ) ; } } return count ; }