#PS0000150. Xâu con dài nhất có từng nguyên âm xuất hiện chẵn lần (Find the Longest Substring Containing Vowels in Even Counts)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Xâu con dài nhất có từng nguyên âm xuất hiện chẵn lần (Find the Longest Substring Containing Vowels in Even Counts)
Find the Longest Substring Containing Vowels in Even Counts
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given a lowercase English string , find the maximum length of a contiguous substring in which each of a, e, i, o, u occurs an even number of times. Zero occurrences count as even. If no nonempty substring qualifies, the result is 0.
Input
One line containing the string of length .
Output
Print the maximum length as one integer.
Subtasks
- Subtask 1 (20 points): ; ; the characters of belong to
abcdefghijklmnopqrstuvwxyz. - Subtask 2 (30 points): ; ; the characters of belong to
bcdfghjklmnpqrstvwxyz. - Subtask 3 (50 points): ; ; the characters of belong to
abcdefghijklmnopqrstuvwxyz.
Example 1
Input
eleetminicoworoep
Output
13
Explanation
Positions 2 through 14 form leetminicowor, with two occurrences each of e, i, o and none of a or u. Every interval of length 14 or more has an odd vowel count.
Example 2
Input
leetcodeisgreat
Output
5
Explanation
The interval leetc contains two e characters. For each length from 6 through 15, the number of qualifying intervals is zero, so 5 is maximal.
Example 3
Input
bcbcbc
Output
6
Explanation
There are no vowels, so the whole six-character string qualifies.