# 2559. Count Vowel Strings in Ranges ###### tags: `Leetcode` `Medium` `Line Sweep` Link: https://leetcode.com/problems/count-vowel-strings-in-ranges/description/ ## Code ```python= class Solution: def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]: vowels = {'a', 'e', 'i', 'o', 'u'} def checkString(word: str) -> bool: return word[0] in vowels and word[-1] in vowels count = [0] for word in words: if checkString(word): count.append(count[-1]+1) else: count.append(count[-1]) ans = [] for start, end in queries: ans.append(count[end+1]-count[start]) return ans ```