class Solution {
public:
bool isValid(string word);
};
bool Solution::isValid(string word) {
int n = word.size();
if (n < 3) {
return false;
}
vector<char> is_vowel(26, false);
vector<char> vowels_list = {'a', 'e', 'i', 'o', 'u'};
for (int i = 0; i < vowels_list.size(); i++) {
is_vowel[vowels_list[i] - 'a'] = true;
}
bool vowel_found = false, consonant_found = false;
for (int i = 0; i < n; i++) {
char ch = word[i];
ch = tolower(ch);
if (ch >= '0' && ch <= '9') {
} else if (ch >= 'a' && ch <= 'z') {
if (is_vowel[ch - 'a']) {
vowel_found = true;
} else {
consonant_found = true;
}
} else {
return false;
}
}
if (vowel_found && consonant_found) {
return true;
}
return false;
}