Connection Status:
Competition Arena > KingXNewBaby
SRM 537 · 2011-11-22 · by fushar · Greedy, Simple Math
Class Name: KingXNewBaby
Return Type: String
Method Name: isValid
Arg Types: (string)
Problem Statement

Problem Statement

King Dengklek is the perfect king of Kingdom of Ducks, where slimes and ducks live together in peace and harmony.

After several years of waiting, King Dengklek and the queen finally had a baby. Now he is looking for a name for the newborn baby. According to the private rule of Kingdom of Ducks, the name of each member of the royal family must be such that:

  • It must consist of exactly eight letters. All letters must be lowercase ('a'-'z').
  • It must have exactly two vowels and six consonants. (Vowels are the letters 'a', 'e', 'i', 'o', and 'u'; the rest are consonants.)
  • The two vowels must be equal.

For example, "dengklek" is a valid name because it consists of exactly eight letters: six consonants and two identical vowels, 'e'.

You are given a String name. Please help the kingdom determine whether name is valid. Return "YES" if it is a valid name for King Dengklek's newborn baby, or "NO" otherwise.

Constraints

  • name will contain between 1 and 50 characters, inclusive.
  • Each character of name will be one of 'a'-'z'.
Examples
0)
"dengklek"
Returns: "YES"
1)
"gofushar"
Returns: "NO"

It has more than two vowels.

2)
"dolphinigle"
Returns: "NO"

It has more than eight letters.

3)
"mystictc"
Returns: "NO"

It has only one vowel.

4)
"rngringo"
Returns: "NO"

It has exactly two vowels, but they are not equal.

5)
"misof"
Returns: "NO"

It has less than eight letters.

Submissions are judged against all 225 archived test cases, of which 6 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class KingXNewBaby with a public method string isValid(string name) · 225 test cases · 2 s / 256 MB per case

Submitting as anonymous