Making Anagrams

0

0 votes
String, Hash table
Problem

Two strings are said to be anagrams of each other if the first string can be formed by rearranging the letters of the second word, or vice versa. In other words, both strings contain the same exact letters in the same exact frequency. For example, abcdc and dcbac are anagrams while abcdc and dcbad are not.

You are given two strings s1 and s2 of equal lengths. You can choose any character of s2 and replace it with any other character. You can repeat this as many times as you want.

Your task is to find the minimum number of such replacements you need to perform so that s2 becomes an anagram of s1

Input

  • First line contains the string s1
  • Second line contains the string s2

Output

Print a single integer, denoting the minimum number of replacements to make s1 and s2 anagrams

Constraints

  • 1 ≤ s1.length ≤ 50000
  • s1.length == s2.length
  • s1 and s2 contain lower-case English letters only.
Sample Input
bab
aba
Sample Output
1
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

You can replace the first 'a' in s2 with b, s2 = "bba" which is anagram of s1

Editor Image

?