easyCountingHash TableString 0 views
Maximum Difference Between Even and Odd Frequency I
You are given a string s consisting of lowercase English letters.
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:
Return this maximum difference.
Example 1
Input: s = "aaaaabbc"
Output: 3
Example 2
Input: s = "abcabcab"
Output: 1
Constraints
- 3 <= s.length <= 100
- s consists only of lowercase English letters.
- s contains at least one character with an odd frequency and one with an even frequency.
Hints
Companies
No companies reported yet.
Discussion
Sign in to join the discussion.
Loading discussion...
Test results
No test cases yet.