Description
Solutions
Has Vowels
π©βπ NEW GRADπRELATED PROBLEMS
Given a string array that contains n
elements, each composed of lowercase English letters, and q
queries, each query of the format i-r
, for each query, determine how many strings starting from index i
and ending at index r
have vowels as the first and last character. Vowels are in {a,e,i,o,u}
.
Function Description
Complete the function hasVowels
in the editor below. It must return an array of integers that represent the result of each query in the order given.
hasVowels
has the following parameters:
strArr string[]
: an array ofn
stringsquery string[]
: an array ofq
strings, each of which describes an intervali-r
using integers delimited by a dash
Example 1:
Input: strArr = ["aba","bcb","ece","aa","e"], queries = ["1-3","2-5","2-2"]
Output: [2, 3, 0]
Explanation:These strings represent two dash delimited integersi
andr
, the start and end indices of the interval, inclusive. Using 1-based indexing in the string array, the interval1-3
contains two strings that start and end with a vowel: 'aba' and 'ece'. The interval2-5
also has three. The third interval, from2-2
, the only element in the interval, 'bcb' does not begin and end with a vowel. The return array for the queries is[2, 3, 0]
.
Constraints:
1 β€ n, q β€ 10^5
1 β€ i β€ r β€ n
1 β€ size of strArr[i] β€ 10

Related Problems
Testcase
Result
Case 1
input:
output: