Skip to content
Onsite

Count Vowel Strings in Ranges

MediumP3Coding

A word is strong if both its first and last characters are lower-case vowels (a, e, i, o, u). A single-letter word that is a vowel is strong.

Each query is [start, end] with 1-based inclusive positions. For each query, return how many words at positions start to end are strong. Return the answers in query order.

Example 1

Input
words = ["apple","banana","eve","dog"], queries = [[1,4],[2,3],[3,3]]
Output
[2,1,1]
Why
"apple" and "eve" are strong.

Example 2

Input
words = ["a"], queries = [[1,1]]
Output
[1]
Why
"banana" and "eve": only "eve" is strong.

Example 3

Input
words = ["b"], queries = [[1,1]]
Output
[0]

Constraints

  • 1 <= words.length <= 10^5
  • 1 <= words[i].length <= 10
  • words[i] consists of lower-case letters
  • 1 <= queries.length <= 10^5
  • 1 <= start <= end <= words.length

Hints

Run checks the 3 visible tests, Submit all 10.