EllysNewNickname
SRM 577 · 2012-12-13 · by espr1t
SRM 577 · 2012-12-13 · by espr1t · Simulation, String Manipulation
Problem Statement
Problem Statement
Elly recently learned that vowels (the letters 'a', 'e', 'i', 'o', 'u' and 'y') are no longer cool on the internet. That's why now she wants to remove some of the vowels in the nickname she uses. Elly wants her new nickname to contain no consecutive vowels, but she still wants to keep as many characters as possible.
You are given the current nickname Elly uses in theString nickname. Return its new length after it gets shortened.
You are given the current nickname Elly uses in the
Notes
- Note that no matter which vowels Elly decides to remove, the length of the resulting nickname will be the same.
- In Elly's language (and in this problem) 'y' is considered a vowel.
Constraints
- nickname will contain between 1 and 50 characters, inclusive.
- nickname will contain only small letters of the English alphabet ('a'-'z').
Examples
0)
"tourist" Returns: 6
The nickname "tourist" can become either "turist" or "torist". Its new length will be 6 characters.
1)
"eagaeoppooaaa" Returns: 6
Although there are many possible resulting nicknames, her strategy guarantees that the length of all of them will be 6. One of the possibilities in this case is "ageppo".
2)
"esprit" Returns: 6
There are cases in which the nickname remains the same.
3)
"ayayayayayaya" Returns: 1
The initial nickname can contain only vowels or only consonants.
4)
"wuuut" Returns: 3
Wut?
Submissions are judged against all 111 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class EllysNewNickname with a public method int getLength(string nickname) · 111 test cases · 2 s / 256 MB per case