← 返回 ibm 的题目列表Count strings starting and ending with vowels in query ranges
类型:online_judge
ibm
Given a string array that contains n elements, each composed of lowercase English letters, and q queries, each query of the format l-r, for each query, determine how many strings starting from index l and ending at index r have vowels as the first and last character. Vowels are {a,e,i,o,u}.
Example
Input:
strArr = ["aba","bcb","cec","ada","eae"]
queries = ["1,3","2,5","2,2"]
Output:[2,3,0]
For the first query, interval 1-3 contains two strings that start and end with a vowel.
For the second query, interval 2-5 contains three strings that start and end with a vowel.
For the third query, interval 2-2 contains no strings that start and end with a vowel.
Function Description
Complete the function hasVowels.
Input parameter:
strArr(n): an array of strings consisting of lowercase letters
queries(q): a list of comma-separated query strings
Return value:
a list of integers representing the result for each query.
Example
Input
5
aba bcb cec ada eae
3
1,3 2,5 2,2