Skip to content

Practice Count Vowel Strings in Ranges

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2559
LeetCode Problem

Count Vowel Strings in Ranges

Problem Statement

You are given a 0-indexed array of strings words and a 2D array of integers queries. Each query queries[i] = [li, ri] asks us to find the number of strings present at the indices ranging from li to ri (both inclusive) of words that start and end with a vowel. Return an array ans of size queries.length, where ans[i] is the answer to the ith query. Note that the vowel letters are 'a', 'e', 'i', 'o', and 'u'.

Source: Count Vowel Strings in Ranges on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

Input
words = ["a","e","i"], queries = [[0,2],[0,1],[2,2]]
Output
[3,2,1]

Constraints

1 <= words.length <= 10^5
1 <= words[i].length <= 40
words[i] consists only of lowercase English letters.
sum(words[i].length) <= 3 * 10^5
1 <= queries.length <= 10^5
0 <= li <= ri < words.length

Related LeetCode Problems

Practice more problems similar to Count Vowel Strings in Ranges.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.