Given a string of house markings, our task is to remove any vowel (a, e, i, o, u) and return the string with only consonants. This will help the committee easily identify the houses that are not being renovated.
Input:"ABEIOU"
Output:"B"
Explanation: The houses marked with vowels (‘A’, ‘E’, ‘I’, ‘O’, ‘U’) will be removed, and only the consonant ‘B’ will remain.
To solve this problem, we need to:
a, e, i, o, u
.house
is a string representing the sequence of house markings.vowels
containing all vowels (both lowercase and uppercase) to ensure that both cases are considered.The time complexity of the algorithm is O(n)O(n), where nn is the length of the input string. We perform a constant-time operation (checking membership in the vowels
string and appending to the result) for each character.
Input:"ABEIOU"
"ABEIOU"
."B"
.Output:"B"
Input:"HOUSE"
"HOUSE"
."HS"
.Output:"HS"
This simple algorithm removes vowels from a string of house markings to help the committee identify the houses that will not be renovated. The solution is efficient and easy to understand, with a time complexity of O(n)O(n). By utilizing a set of vowels and filtering out the non-vowel characters, we achieve the desired result with minimal effort. Click here to know more our program!