Minimum Replacements to Make Two Strings Anagrams
Problem statement
Return the minimum number of positions in first whose characters must be replaced so first and second are anagrams. Return -1 if their lengths differ.
Function
minimumAnagramReplacements(first: String, second: String) → intExamples
Example 1
first = "bab"second = "aba"return = 1Replacing one b with a equalizes the character counts.
Constraints
- Both strings contain lowercase English letters.
- Each length is at most
10^5.