Problem
Given a string S
, remove the vowels a
, e
, i
, o
, and u
from it, and return the new string.
example 1
1
2
|
Input: "leetcodeisacommunityforcoders"
Output: "ltcdscmmntyfrcdrs"
|
example 2
1
2
|
Input: "aeiou"
Output: ""
|
Constraints
S
consists of lowercase English letters only.
- 1 <=
len(S)
<= 1000
Solution
Walk throw string and remove vowels
1
2
3
4
5
6
7
8
9
10
11
|
func removeVowels(S string) string {
res := ""
for idx:=range S {
if S[idx] != 'a' && S[idx] != 'e' && S[idx] != 'i' && S[idx] != 'o' && S[idx] != 'u' {
res += string(S[idx])
}
}
return res
}
|