#K48802. Minimum Steps to Make Two Strings Anagrams
Minimum Steps to Make Two Strings Anagrams
Minimum Steps to Make Two Strings Anagrams
Given two strings (A) and (B), determine the minimum number of steps required to make them anagrams. Two strings are anagrams if they consist of the same characters with the same frequencies (order is not important). In one step, you can insert, delete, or replace a character in one of the strings. For this problem, the optimal approach is to count the frequency differences of each character between (A) and (B). The minimum number of steps is given by [ \sum_{c \in {a,\ldots,z}} \left|count_A(c) - count_B(c)\right| ] where (count_A(c)) and (count_B(c)) denote the frequency of character (c) in (A) and (B) respectively.
inputFormat
The input consists of two lines. The first line contains the string (A), and the second line contains the string (B). Both strings consist solely of lowercase English letters. Note that one or both strings may be empty.
outputFormat
Output a single integer representing the minimum number of steps required to make the two strings anagrams by adjusting the characters based on their frequency differences.## sample
abcd
cbda
0
</p>