1119. Remove Vowels from a String¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12 13 14class Solution { public: string removeVowels(string s) { s.erase(remove_if(s.begin(), s.end(), [&](char c) { return isVowel(c); }), s.end()); return s; } private: bool isVowel(char c) { static constexpr string_view kVowels = "aeiou"; return kVowels.find(c) != string_view::npos; } }; 1 2 3 4 5class Solution { public String removeVowels(String s) { return s.replaceAll("[aeiou]", ""); } } 1 2 3class Solution: def removeVowels(self, s: str) -> str: return re.sub('a|e|i|o|u', '', s)