Find Most Frequent Vowel and Consonant

You are given a string `s` of lowercase English letters. The vowels are 'a', 'e', 'i', 'o' and 'u'; every other letter is a consonant. Find the highest frequency of any single vowel and the highest frequency of any single consonant, and return their sum. If the string has no vowels (or no consonants), that part counts as 0.

30:00

Find Most Frequent Vowel and Consonant
easy
Free written solution
Topics
Companies

You are given a string s of lowercase English letters. The vowels are 'a', 'e', 'i', 'o' and 'u'; every other letter is a consonant. Find the highest frequency of any single vowel and the highest frequency of any single consonant, and return their sum. If the string has no vowels (or no consonants), that part counts as 0.

Example 1:
Input: {"s":"successes"}
Output: 6
Constraints:
  • 1≤s.length≤1001 \leq s.\text{length} \leq 100

  • s consists of lowercase English letters only.

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"s":"successes"}

Make 26 empty buckets, one per letter: a, e, i, o, u go on the vowel shelf, the other 21 on the consonant shelf.

s (vowels pink, consonants blue)

s
u
c
c
e
s
s
e
s

vowel shelf

aeiou

consonant shelf

bcdfghjklmnpqrstvwxyz

vowel ? + consonant ?

Variables
VariableValue
n9
DepthFunction Call
Stack empty
0/15