#3442
Maximum Difference Between Even and Odd Frequency I
easy · premium · 60.7% accepted · 394 likes · top 60%
hash table · string · counting
Description
You are given a string s consisting of lowercase English letters.
Your task is to find the maximum difference diff = freq(a1) - freq(a2) between the frequency of characters a1 and a2 in the string such that:
- a1 has an odd frequency in the string.
- a2 has an even frequency in the string.
Return this maximum difference.
Solution