# 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 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up