File: remove-vowels-from-a-string/solution.py

Date: 2026-06-06

Time: 18:49

remove-vowels-from-a-string/solution.py

Purpose

This file implements the solution to LeetCode 1119 — Remove Vowels from a String. It owns exactly one responsibility: given a string of lowercase English letters, return the string with all vowels (a, e, i, o, u) removed.

Key Components

Solution.removeVowels(self, s: str) -> str — The single method, following LeetCode's expected class/method signature. It takes a lowercase English string and returns a new string with vowels filtered out.

The implementation is a one-liner: a generator expression filters each character against the string literal "aeiou", and str.join assembles the result.

Patterns

Dependencies

Imports: None. The solution uses only Python builtins.

Imported by: The "Imported By" list in the prompt is misleading — those ~400+ test files don't actually import *this* solution. They each import their *own* solution.py via a relative or same-directory import. The only real consumer is remove-vowels-from-a-string/test_solution.py.

Flow

1. Iterate over each character c in input s.

2. For each c, check membership against the vowel string "aeiou".

3. Yield c only if it is *not* a vowel.

4. "".join(...) concatenates all yielded characters into the result string.

Single pass, O(n) time, O(n) space for the output string.

Invariants

Error Handling

None. No validation, no exceptions. An empty string input produces an empty string output — the generator simply yields nothing and join returns "". This is correct behavior, not a gap.

Topics to Explore

Beliefs