class Solution {
private:
int modify(char& ch) {
switch (ch) {
case 'a' : return 0;
case 'e' : return 1;
case 'i' : return 2;
case 'o' : return 3;
case 'u' : return 4;
default: return -1;
}
}
public:
int findTheLongestSubstring(string s) {
int n = s.length();
array<int, 32> prefixMap;
fill(prefixMap.begin(), prefixMap.end(), -2);
prefixMap[0] = -1;
int res = 0, status = 0;
for (int i = 0; i < n; i++) {
int bit = modify(s[i]);
if (bit != -1) {
status ^= 1 << bit;
}
if (prefixMap[status] != -2) {
res = max(res, i - prefixMap[status]);
} else {
prefixMap[status] = i;
}
}
return res;
}
};