Skip to main content
Back to problems
#1119
Easy Algorithms

Remove vowels from a string

String
91.3% acceptance
Mar 31, 2026
368
116
Given a string s, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string.

Solution

Rust
Time O(n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn remove_vowels(s: String) -> String {
    s.chars().filter(|c| !matches!(c, 'a' | 'e' | 'i' | 'o' | 'u')).collect()
  }
}