1119. Remove Vowels from a String
Given a string S, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string.
Example 1:
Input: "leetcodeisacommunityforcoders"
Output: "ltcdscmmntyfrcdrs"Example 2:
Input: "aeiou"
Output: ""Note:
Sconsists of lowercase English letters only.1 <= S.length <= 1000
string removeVowels(string S) { // time: O(n); space: O(n)
if (S.empty()) return S;
int n = S.length();
string vowels = "aeiouAEIOU", res;
for (int i = 0 ; i < n; ++i) {
if (vowels.find(S[i]) == string::npos) res += S[i];
}
return res;
}Previous1108. Defanging an IP AddressNext1170. Compare Strings by Frequency of the Smallest Character
Last updated
Was this helpful?