-
Notifications
You must be signed in to change notification settings - Fork 43
/
remove-vowels-from-a-string.py
57 lines (46 loc) · 1.09 KB
/
remove-vowels-from-a-string.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
# https://blog.csdn.net/fuxuemingzhu/article/details/100976794
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"
1
2
Example 2:
Input: "aeiou"
Output: ""
1
2
Note:
S consists of lowercase English letters only.
1 <= S.length <= 1000
"""
# V0
class Solution:
def removeVowels(self, S):
res = ""
vowel = {'a','e','i','o','u'}
for i in S:
if i not in vowel:
res += i
return res
# V1
# https://www.twblogs.net/a/5d5f289ebd9eee541c328825
class Solution:
def removeVowels(self, S: str) -> str:
res=''
a={'a','e','i','o','u'}
for i in S:
if i not in a:
res+=i
return res
# V1'
# https://zhongwen.gitbook.io/leetcode-report/easy/1119.-remove-vowels-from-a-string
class Solution:
def removeVowels(self, S):
res = ""
vowel = {'a','e','i','o','u'}
for i in S:
if i not in vowel:
res += i
return res