LeetCode Entry

3541. Find Most Frequent Vowel and Consonant

13.09.2025 easy 2025 kotlin

Max freq vowels + consonants

3541. Find Most Frequent Vowel and Consonant easy blog post substack youtube

1.webp

Join me on Telegram

https://t.me/leetcode_daily_unstoppable/1111

Problem TLDR

Max freq vowels + consonants #easy

Intuition

Make a frequency array, then find max of vowel and max of consonant.

Approach

  • can we do a one-liner?

Complexity

  • Time complexity: \(O(n)\)

  • Space complexity: \(O(n)\)

Code


// 27ms
    fun maxFreqSum(s: String) = s.partition { it in "aeiou" }.toList()
        .sumOf { it.groupBy { it }.maxOfOrNull { it.value.size } ?: 0 }