Description
Solutions
Has Vowels
πŸ‘©β€πŸŽ“ NEW GRAD

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:

  1. strArr string[]: an array of n strings
  2. query string[]: an array of q strings, each of which describes an interval i-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 integers i and r, the start and end indices of the interval, inclusive. Using 1-based indexing in the string array, the interval 1-3 contains two strings that start and end with a vowel: 'aba' and 'ece'. The interval 2-5 also has three. The third interval, from 2-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
Thumbnail 0
Testcase

Result
Case 1

input:

output: