3442. Maximum Difference Between Even and Odd Frequency I

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:

def maxDifference(self, s: str) -> int:
	d = {}
	for ch in s:
		if ch not in d:
			d[ch] = 1
		else:
			d[ch] += 1
	even , odd = [], []
	for i in d.values():
		if i % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	return max(odd) - min(even)