---
###### tags: `Leetcode`
---
# Leetcode 1119. Remove Vowels from a String
[link](https://leetcode.com/problems/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: ""
#### Constraints:
- S consists of lowercase English letters only.
- 1 <= S.length <= 1000
---
Create a new string and append only consonants to the new string. Use a StringBuffer, which is initially empty, and loop over the original string S and add the consonants to the StringBuffer. Finally, return the string converted from the StringBuffer.
#### Solution 1
```python=
class Solution:
def removeVowels(self, s: str) -> str:
res = []
for c in s:
if c not in {'a', 'e', 'i', 'o', 'u'}:
res.append(c)
return ''.join(res)
```
O(T): O(N)
O(S): O(N)
---
Using replace function to remove the vowels in the given string and return the original string without extra space.
#### Solution 2
```python=
class Solution:
def removeVowels(self, s: str) -> str:
replacements = ['a', 'e', 'i', 'o', 'u']
for i in replacements:
s = s.replace(i, "")
return s
```
O(T): O(N)
O(S): O(1)