2586. Count the Number of Vowel Strings in Range 發表於 2023-03-19 | 分類於 leetcode problemsolution1234567891011121314class Solution {public: unordered_set<char> vowels = {'a','e','i', 'o','u'}; bool isValid(string word) { return vowels.count(word.front()) && vowels.count(word.back()); } int vowelStrings(vector<string>& words, int left, int right) { int count = 0; for(int i=left ; i<=right ; ++i) { if(isValid(words[i])) count++; } return count; }}; analysis time complexity O(n) space complexity O(1)