# https://leetcode.com/problems/count-vowel-strings-in-ranges from typing import List VOWEL = { 'a': True, 'e': True, 'i': True, 'o': True, 'u': True, } class Solution: def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]: sums = [0] for word in words: if word[0] in VOWEL and word[-1] in VOWEL: sums.append(sums[-1] + 1) else: sums.append(sums[-1]) result = [] for [start, end] in queries: result.append(sums[end + 1] - sums[start]) return result