You are given a lowercase English string s.
Your task is to determine:
The vowel ('a', 'e', 'i', 'o', 'u') that appears the most times in the string.
The consonant (all other alphabet letters) that appears the most times.
You must return the sum of these two maximum frequencies.
If the string contains no vowels, treat the vowel frequency as 0.
If the string contains no consonants, treat the consonant frequency as 0.
In case of ties between letters, any of them may be chosen.
Input: s = "programming"
Output: 7
Explanation:
Vowel frequencies: o → 1 a → 1 i → 1 Max vowel freq = 1 Consonant frequencies: g → 2 r → 2 m → 2 p, n → 1 Max consonant freq = 2 Result = 1 + 5 = 6? Wait—check again. Let’s recount: programming contains: g = 2 r = 2 m = 2 n = 1 p = 1 o = 1 a = 1 i = 1 Max vowel = 1 Max consonant = 3 (because: 'g'=2, 'r'=2, 'm'=2 → 2) Correction: no consonant appears 3 times So max consonant = 2 Final = 1 + 2 = 3 Correct Output: 3
Input: s = "bookkeeper"
Output: 6
Explanation:
Vowel counts: o → 2 e → 3 Max vowel freq = 3 Consonant counts: k → 2 p, b, r → 1 Max consonant freq = 2 Total = 3 + 2 = 5 But k = 2, correct. Output = 5
Accepted:
Submission: