Find the Longest Substring Containing Vowels in Even Counts

Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, a, e, i, o, and u must appear an even number of times.

Example 1
Inputs = "eleetminicoworoep"
Output13
The longest substring is "leetminicowor", which contains two each of the vowels e, i, and o and zero of the vowels a and u.
Example 2
Inputs = "leetcodeisgreat"
Output5
The longest substring is "leetc", which contains two e's.

Constraints

  • 1 <= s.length <= 5 x 10^5
  • s contains only lowercase English letters.

Asked at 6 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate