Connection Status:
Competition Arena > VowelCount
Rookie SRM 19 · 2023-03-17 · by erinn · Simple Search, Iteration
Class Name: VowelCount
Return Type: int
Method Name: getCount
Arg Types: (string)
Problem Statement

Problem Statement

Words are composed of two types of letters, vowels and consonants. For purposes of our problem, 'a', 'e', 'i', 'o', and 'u' are vowels, and all other letters are consonants.

Given a String word, return the number of vowels it contains.

Constraints

  • word will contain between 1 and 10 characters, inclusive.
  • Each character of word will be a lower-case letter ('a'-'z').
Examples
0)
"kayak"
Returns: 2

There are two 'a' letters.

1)
"rhythm"
Returns: 0

There are no vowels at all.

2)
"strength"
Returns: 1

Just one vowel here.

3)
"abcdefghij"
Returns: 3
4)
"aaaaaaaa"
Returns: 8
Coding Area

Language: C++17 · define a public class VowelCount with a public method int getCount(string word) · 5 test cases · 2 s / 256 MB per case

Submitting as anonymous