[LeetCode] Remove Vowels from a String

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.

1
2
3
4
5
6
7
8
9
10
11
class Solution {
public:
string removeVowels(string s) {
string res = "";
for(auto ch : s) {
if(ch == 'a' or ch == 'i' or ch == 'e' or ch == 'o' or ch == 'u') continue;
res.push_back(ch);
}
return res;
}
};
Author: Song Hayoung
Link: https://songhayoung.github.io/2024/03/22/PS/LeetCode/remove-vowels-from-a-string/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.