2559. Count Vowel Strings in Ranges Medium
1/**
2 * [2559] Count Vowel Strings in Ranges
3 *
4 * You are given a 0-indexed array of strings words and a 2D array of integers queries.
5 * Each query queries[i] = [li, ri] asks us to find the number of strings present in the range li to ri (both inclusive) of words that start and end with a vowel.
6 * Return an array ans of size queries.length, where ans[i] is the answer to the i^th query.
7 * Note that the vowel letters are 'a', 'e', 'i', 'o', and 'u'.
8 *
9 * <strong class="example">Example 1:
10 *
11 * Input: words = ["aba","bcb","ece","aa","e"], queries = [[0,2],[1,4],[1,1]]
12 * Output: [2,3,0]
13 * Explanation: The strings starting and ending with a vowel are "aba", "ece", "aa" and "e".
14 * The answer to the query [0,2] is 2 (strings "aba" and "ece").
15 * to query [1,4] is 3 (strings "ece", "aa", "e").
16 * to query [1,1] is 0.
17 * We return [2,3,0].
18 *
19 * <strong class="example">Example 2:
20 *
21 * Input: words = ["a","e","i"], queries = [[0,2],[0,1],[2,2]]
22 * Output: [3,2,1]
23 * Explanation: Every string satisfies the conditions, so we return [3,2,1].
24 *
25 * Constraints:
26 *
27 * 1 <= words.length <= 10^5
28 * 1 <= words[i].length <= 40
29 * words[i] consists only of lowercase English letters.
30 * sum(words[i].length) <= 3 * 10^5
31 * 1 <= queries.length <= 10^5
32 * 0 <= li <= ri < words.length
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/count-vowel-strings-in-ranges/
38// discuss: https://leetcode.com/problems/count-vowel-strings-in-ranges/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn vowel_strings(words: Vec<String>, queries: Vec<Vec<i32>>) -> Vec<i32> {
44 vec![]
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_2559() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.