#3442

Maximum Difference Between Even and Odd Frequency I

pupil · 385 · lc easy +24 · premium · 60.7% accepted · 394 likes · top 60%

Description

You are given a string s of lowercase English letters.

Find the maximum difference diff = freq(a1) - freq(a2) among all character pairs where:

- a1 has an odd frequency in s.

- a2 has an even frequency in s.

Return this maximum difference.

Code

1
2
3