Given two strings s and t, you need to find the minimum number of character additions to make them anagrams of each other.
In each step, you can append any character to either string s or string t. Your goal is to transform both strings so they contain exactly the same characters with the same frequencies.
What is an anagram? An anagram is a rearrangement of characters from one word to form another word using all characters exactly once. For example, "listen" and "silent" are anagrams.
Example: If s = "leetcode" and t = "coats", we need to add characters to make them anagrams. The optimal solution requires adding specific characters to balance the character frequencies between both strings.
Input & Output
Constraints
- 1 โค s.length, t.length โค 5 ร 104
- s and t consist of lowercase English letters only
- Follow up: Can you solve this in O(1) space complexity?