1371. Find the Longest Substring Containing Vowels in Even Counts
Practice Find the Longest Substring Containing Vowels in Even Counts for free on NudgeCode: Medium, Bit Manipulation pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Given a lowercase string s, return the length of the longest contiguous substring in which each of the vowels a, e, i, o, u occurs an even number of times. Zero counts as even, and consonants can occur any number of times. The empty substring always qualifies, so the answer is at least 0.
Example
s = "eleetminicoworoep" -> 13 ("leetminicowor")
s = "bcbcbc" -> 6 (no vowels at all)
s = "a" -> 0
Constraints
- 1 <= s.length <= 5 * 10^5
- s contains only lowercase English letters