#1371

Find the Longest Substring Containing Vowels in Even Counts

pupil · 485 · lc medium +27 · verified · 75.7% accepted · 2,559 likes · top 87%

Description

Given the string s, return the length of the longest substring in which every vowel ('a', 'e', 'i', 'o', 'u') appears an even number of times (zero counts as even).

Example 1:

Input: s = "eleetminicoworoep"
Output: 13
Explanation: 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:

Input: s = "leetcodeisgreat"
Output: 5
Explanation: The longest substring is "leetc" which contains two e's.

Example 3:

Input: s = "bcbcbc"
Output: 6
Explanation: In this case, the given string "bcbcbc" is the longest because all vowels: a, e, i, o and u appear zero times.

Code

1
2
3