###### tags: `leetcode` # leetcode 1119 這題是premium才能看的題,不過google可以找到,一樣複製過來,希望之後找的可以是非premium都能使用的題目 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. Example 1: Input: "leetcodeisacommunityforcoders" Output: "ltcdscmmntyfrcdrs" Example 2: Input: "aeiou" Output: "" Note: S consists of lowercase English letters only. 1 <= S.length <= 1000 ``` class Solution: def RemoveVowels(self, S:str) -> str: S.replace('a','') S.replace('e','') S.replace('i','') S.replace('o','') return S.replace('u','') ``` 這邊的replace()是python內建函式,用後一引數取代字串內前一引數,複雜度為O(N)