Count Vowel Strings in Ranges

Medium

Description

Given an array of string queries and strings, for each query find the count of strings where the query is a prefix and string only contains vowels.

Examples

Input:words = ["aba","bcb","ece","aa","e"], queries = [[0,2],[1,4],[1,1]]
Output:[2,3,0]
Explanation:

Counts for each range.

Input:words = ["aba","bcb","ece","aa","e"], queries = [[1]]
Output:[1]
Explanation:

Minimal case with a single query.

Input:words = ["apple", "orange", "banana", "ice", "umbrella", "hello"], queries = [[0,5],[2,4],[3,3]]
Output:[4,2,1]
Explanation:

For range [0,5]: "apple" (a-e), "orange" (o-e), "ice" (i-e), "umbrella" (u-a) start and end with vowels, so count is 4. For range [2,4]: "ice" (i-e) and "umbrella" (u-a) qualify, so count is 2. For range [3,3]: only "ice" (i-e) qualifies, so count is 1.

Constraints

  • 1 ≤ words.length ≤ 10⁵

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!