2586. 统计范围内的元音字符串数
给你一个下标从 0 开始的字符串数组 words 和两个整数:left 和 right 。
如果字符串以元音字母开头并以元音字母结尾,那么该字符串就是一个 元音字符串 ,其中元音字母是 ‘a’、‘e’、‘i’、‘o’、‘u’ 。
返回 words[i] 是元音字符串的数目,其中 i 在闭区间 [left, right] 内。
提示:
class Solution {
bool judged(char ch){
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
return true;
}
return false;
}
bool judge(string s){
if(judged(s[0]) == true && judged(s[s.size()-1]) == true){
return true;
}
return false;
}
public:
int vowelStrings(vector& words, int left, int right) {
int res = 0;
for(int i = left; i <= right; ++i){
if(judge(words[i]) == true){
++res;
}
}
return res;
}
};
(1) 直接模拟即可。