#C7927. Minimum Deletions to Make Two Strings Anagrams
Minimum Deletions to Make Two Strings Anagrams
Minimum Deletions to Make Two Strings Anagrams
Given two strings \(X\) and \(Y\), determine the minimum number of character deletions required so that they become anagrams of each other. Two strings are anagrams if they have the same frequency of each character. Mathematically, the number of deletions required can be expressed as:
$$\text{Deletions} = \sum_{c \in \{a,\ldots,z\}} \left| f_X(c) - f_Y(c) \right|$$
where \(f_X(c)\) and \(f_Y(c)\) denote the frequency of character \(c\) in strings \(X\) and \(Y\) respectively.
The input strings consist of lowercase English letters. In cases where one or both strings are empty, the function should correctly compute the total number of deletions needed.
inputFormat
The input consists of two lines:
- The first line contains the string \(X\).
- The second line contains the string \(Y\).
outputFormat
Output a single integer representing the minimum number of deletions required so that the two strings become anagrams of each other.
## samplesilent
listen
0