2025-09-13 15:48:49 +0000 UTC

Find Most Frequent Vowel and Consonant

Code

class Solution:
    def maxFreqSum(self, s: str) -> int:
        freqs = [0] * 26
        for char in s:
            freqs[ord(char) - 97] += 1
        max_vow, max_con = 0, 0
        for i in range(26):
            if chr(i + 97) in ("a", "e", "i", "o", "u"):
                max_vow = max(max_vow, freqs[i])
            else:
                max_con = max(max_con, freqs[i])
        return max_vow + max_con