[
string
]
Leetcode 1119 Remove Vowels from a String
Problem statement
https://leetcode.com/problems/remove-vowels-from-a-string/
Solution
Just iterate through string and check if we need to take symbol or not.
Complexity
Time complexity is O(n*5)
, where n
is the length of s
, space complexity is O(n)
. Time can be improved to O(n)
, if we create set of vowels in advance.
Code
class Solution:
def removeVowels(self, s):
return "".join(i for i in s if i not in "aeiou")