LeetCode

3442. Maximum Difference Between Even and Odd Frequency I

Easy


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

Explanation:

Example 2:

Input: s = "abcabcab"

Output: 1

Explanation:

 

Constraints: