java.lang.Object
g2501_2600.s2559_count_vowel_strings_in_ranges.Solution

public class Solution extends Object
2559 - Count Vowel Strings in Ranges.<p>Medium</p> <p>You are given a <strong>0-indexed</strong> array of strings <code>words</code> and a 2D array of integers <code>queries</code>.</p> <p>Each query <code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code> asks us to find the number of strings present in the range <code>l<sub>i</sub></code> to <code>r<sub>i</sub></code> (both <strong>inclusive</strong> ) of <code>words</code> that start and end with a vowel.</p> <p>Return <em>an array</em> <code>ans</code> <em>of size</em> <code>queries.length</code><em>, where</em> <code>ans[i]</code> <em>is the answer to the</em> <code>i</code><sup>th</sup> <em>query</em>.</p> <p><strong>Note</strong> that the vowel letters are <code>'a'</code>, <code>'e'</code>, <code>'i'</code>, <code>'o'</code>, and <code>'u'</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> words = [&ldquo;aba&rdquo;,&ldquo;bcb&rdquo;,&ldquo;ece&rdquo;,&ldquo;aa&rdquo;,&ldquo;e&rdquo;], queries = [[0,2],[1,4],[1,1]]</p> <p><strong>Output:</strong> [2,3,0]</p> <p><strong>Explanation:</strong> The strings starting and ending with a vowel are &ldquo;aba&rdquo;, &ldquo;ece&rdquo;, &ldquo;aa&rdquo; and &ldquo;e&rdquo;.</p> <p>The answer to the query [0,2] is 2 (strings &ldquo;aba&rdquo; and &ldquo;ece&rdquo;).</p> <p>to query [1,4] is 3 (strings &ldquo;ece&rdquo;, &ldquo;aa&rdquo;, &ldquo;e&rdquo;).</p> <p>to query [1,1] is 0.</p> <p>We return [2,3,0].</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> words = [&ldquo;a&rdquo;,&ldquo;e&rdquo;,&ldquo;i&rdquo;], queries = [[0,2],[0,1],[2,2]]</p> <p><strong>Output:</strong> [3,2,1]</p> <p><strong>Explanation:</strong> Every string satisfies the conditions, so we return [3,2,1].</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= words.length <= 10<sup>5</sup></code></li> <li><code>1 <= words[i].length <= 40</code></li> <li><code>words[i]</code> consists only of lowercase English letters.</li> <li><code>sum(words[i].length) <= 3 * 10<sup>5</sup></code></li> <li><code>1 <= queries.length <= 10<sup>5</sup></code></li> <li><code>0 <= l<sub>i</sub> <= r<sub>i</sub> < words.length</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • vowelStrings

      public int[] vowelStrings(String[] words, int[][] queries)