Remove Vowels from a String - Problem
Given a string s, remove all vowels ('a', 'e', 'i', 'o', and 'u') from it and return the new string.
Note: The vowels are case-sensitive, so only lowercase vowels should be removed.
Input & Output
Example 1 — Basic Case
$
Input:
s = "leetcode"
›
Output:
"ltcd"
💡 Note:
Remove vowels 'e', 'e', 'o', 'e' from "leetcode" to get "ltcd"
Example 2 — Mixed Case
$
Input:
s = "aEiOu"
›
Output:
"EOU"
💡 Note:
Only lowercase vowels are removed: 'a', 'i', 'u'. Uppercase 'E', 'O', 'U' remain
Example 3 — No Vowels
$
Input:
s = "bcdfg"
›
Output:
"bcdfg"
💡 Note:
String contains no lowercase vowels, so it remains unchanged
Constraints
- 1 ≤ s.length ≤ 1000
- s consists of lowercase and uppercase English letters
Visualization
Tap to expand
Understanding the Visualization
1
Input
Original string with vowels and consonants
2
Filter
Identify and remove lowercase vowels a,e,i,o,u
3
Output
New string containing only consonants and uppercase letters
Key Takeaway
🎯 Key Insight: Use efficient string building to avoid quadratic time complexity from concatenation
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code