LeetCode 1371, Medium. Topics: String, Bit Manipulation, Prefix Sum. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 26 parametrized pytest cases, and a playground notebook:
Problem
Given the string <code>s</code>, return the size of the longest substring containing each vowel an even number of times. That is, <code>‘a’</code>, <code>‘e’</code>, <code>‘i’</code>, <code>‘o’</code>, and <code>‘u’</code> must appear an even number of times.
Examples
Constraints
- 1 <= s.length <= 5 x 10^5
- s contains only lowercase English letters.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026