<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>vowel Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/tag/vowel/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/tag/vowel/</link>
	<description></description>
	<lastBuildDate>Sun, 12 Mar 2023 04:35:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>vowel Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/tag/vowel/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>花花酱 LeetCode 2586. Count the Number of Vowel Strings in Range</title>
		<link>https://zxi.mytechroad.com/blog/string/leetcode-2586-count-the-number-of-vowel-strings-in-range/</link>
					<comments>https://zxi.mytechroad.com/blog/string/leetcode-2586-count-the-number-of-vowel-strings-in-range/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 12 Mar 2023 04:32:34 +0000</pubDate>
				<category><![CDATA[String]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[vowel]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=9977</guid>

					<description><![CDATA[<p>You are given a&#160;0-indexed&#160;array of string&#160;words&#160;and two integers&#160;left&#160;and&#160;right. A string is called a&#160;vowel string&#160;if it starts with a vowel character and ends with a vowel&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-2586-count-the-number-of-vowel-strings-in-range/">花花酱 LeetCode 2586. Count the Number of Vowel Strings in Range</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>You are given a&nbsp;<strong>0-indexed</strong>&nbsp;array of string&nbsp;<code>words</code>&nbsp;and two integers&nbsp;<code>left</code>&nbsp;and&nbsp;<code>right</code>.</p>



<p>A string is called a&nbsp;<strong>vowel string</strong>&nbsp;if it starts with a vowel character and ends with a vowel character where vowel characters are&nbsp;<code>'a'</code>,&nbsp;<code>'e'</code>,&nbsp;<code>'i'</code>,&nbsp;<code>'o'</code>, and&nbsp;<code>'u'</code>.</p>



<p>Return&nbsp;<em>the number of vowel strings&nbsp;</em><code>words[i]</code><em>&nbsp;where&nbsp;</em><code>i</code><em>&nbsp;belongs to the inclusive range&nbsp;</em><code>[left, right]</code>.</p>



<p><strong>Example 1:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> words = ["are","amy","u"], left = 0, right = 2
<strong>Output:</strong> 2
<strong>Explanation:</strong> 
- "are" is a vowel string because it starts with 'a' and ends with 'e'.
- "amy" is not a vowel string because it does not end with a vowel.
- "u" is a vowel string because it starts with 'u' and ends with 'u'.
The number of vowel strings in the mentioned range is 2.
</pre>



<p><strong>Example 2:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> words = ["hey","aeo","mu","ooo","artro"], left = 1, right = 4
<strong>Output:</strong> 3
<strong>Explanation:</strong> 
- "aeo" is a vowel string because it starts with 'a' and ends with 'o'.
- "mu" is not a vowel string because it does not start with a vowel.
- "ooo" is a vowel string because it starts with 'o' and ends with 'o'.
- "artro" is a vowel string because it starts with 'a' and ends with 'o'.
The number of vowel strings in the mentioned range is 3.
</pre>



<p><strong>Constraints:</strong></p>



<ul><li><code>1 &lt;= words.length &lt;= 1000</code></li><li><code>1 &lt;= words[i].length &lt;= 10</code></li><li><code>words[i]</code>&nbsp;consists of only lowercase English letters.</li><li><code>0 &lt;= left &lt;= right &lt; words.length</code></li></ul>



<h2><strong>Solution:</strong></h2>



<p>Iterator overs words, from left to right. Check the first and last element of the string.</p>



<p>Time complexity: O(|right &#8211; left + 1|)<br>Space complexity: O(1)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  int vowelStrings(vector&lt;string&gt;&amp; words, int left, int right) {
    auto isVowel = [](char c) {
      return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
    };
    return count_if(begin(words) + left, begin(words) + right + 1, [&amp;](const string&amp; w) {
      return isVowel(w.front()) &amp;&amp; isVowel(w.back());
    });
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-2586-count-the-number-of-vowel-strings-in-range/">花花酱 LeetCode 2586. Count the Number of Vowel Strings in Range</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/string/leetcode-2586-count-the-number-of-vowel-strings-in-range/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 2559. Count Vowel Strings in Ranges</title>
		<link>https://zxi.mytechroad.com/blog/algorithms/array/leetcode-2559-count-vowel-strings-in-ranges/</link>
					<comments>https://zxi.mytechroad.com/blog/algorithms/array/leetcode-2559-count-vowel-strings-in-ranges/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 05 Feb 2023 05:25:04 +0000</pubDate>
				<category><![CDATA[Array]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[prefix sum]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[vowel]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=9929</guid>

					<description><![CDATA[<p>You are given a&#160;0-indexed&#160;array of strings&#160;words&#160;and a 2D array of integers&#160;queries. Each query&#160;queries[i] = [li, ri]&#160;asks us to find the number of strings present in&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/array/leetcode-2559-count-vowel-strings-in-ranges/">花花酱 LeetCode 2559. Count Vowel Strings in Ranges</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>You are given a&nbsp;<strong>0-indexed</strong>&nbsp;array of strings&nbsp;<code>words</code>&nbsp;and a 2D array of integers&nbsp;<code>queries</code>.</p>



<p>Each query&nbsp;<code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code>&nbsp;asks us to find the number of strings present in the range&nbsp;<code>l<sub>i</sub></code>&nbsp;to&nbsp;<code>r<sub>i</sub></code>&nbsp;(both&nbsp;<strong>inclusive</strong>) of&nbsp;<code>words</code>&nbsp;that start and end with a vowel.</p>



<p>Return an array&nbsp;<code>ans</code>&nbsp;of size&nbsp;<code>queries.length</code>, where&nbsp;<code>ans[i]</code>&nbsp;is the answer to the&nbsp;<code>i</code><sup>th</sup>&nbsp;query.</p>



<p><strong>Note</strong>&nbsp;that the vowel letters are&nbsp;<code>'a'</code>,&nbsp;<code>'e'</code>,&nbsp;<code>'i'</code>,&nbsp;<code>'o'</code>, and&nbsp;<code>'u'</code>.</p>



<p><strong>Example 1:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> words = ["aba","bcb","ece","aa","e"], queries = [[0,2],[1,4],[1,1]]
<strong>Output:</strong> [2,3,0]
<strong>Explanation:</strong> The strings starting and ending with a vowel are "aba", "ece", "aa" and "e".
The answer to the query [0,2] is 2 (strings "aba" and "ece").
to query [1,4] is 3 (strings "ece", "aa", "e").
to query [1,1] is 0.
We return [2,3,0].
</pre>



<p><strong>Example 2:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> words = ["a","e","i"], queries = [[0,2],[0,1],[2,2]]
<strong>Output:</strong> [3,2,1]
<strong>Explanation:</strong> Every string satisfies the conditions, so we return [3,2,1].</pre>



<p><strong>Constraints:</strong></p>



<ul><li><code>1 &lt;= words.length &lt;= 10<sup>5</sup></code></li><li><code>1 &lt;= words[i].length &lt;= 40</code></li><li><code>words[i]</code>&nbsp;consists only of lowercase English letters.</li><li><code>sum(words[i].length) &lt;= 3 * 10<sup>5</sup></code></li><li><code>1 &lt;= queries.length &lt;= 10<sup>5</sup></code></li><li><code>0 &lt;= l<sub>i</sub> &lt;= r<sub>i</sub> &lt;&nbsp;words.length</code></li></ul>



<h2><strong>Solution: Prefix Sum</strong></h2>



<p>Let sum[i] := number of valid strings in words[0:i]</p>



<p>For each query [l, r], answer will be sum[r + 1] &#8211; sum[l]</p>



<p>Time complexity: O(n + q)<br>Space complexity: O(n)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">// Author: Huahua
class Solution {
public:
  vector&lt;int&gt; vowelStrings(vector&lt;string&gt;&amp; words, vector&lt;vector&lt;int&gt;&gt;&amp; queries) {
    const size_t n = words.size();
    vector&lt;int&gt; sum(n + 1);
    auto check = [](char c) {
      return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
    };
    for (size_t i = 0; i &lt; n; ++i)
      sum[i + 1] = sum[i] + 
        (check(words[i][0]) &amp;&amp; check(words[i][words[i].size() - 1]));
    vector&lt;int&gt; ans;
    for (const auto&amp; q : queries)
      ans.push_back(sum[q[1] + 1] - sum[q[0]]);
    return ans;
  }
};</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/algorithms/array/leetcode-2559-count-vowel-strings-in-ranges/">花花酱 LeetCode 2559. Count Vowel Strings in Ranges</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/algorithms/array/leetcode-2559-count-vowel-strings-in-ranges/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 1704. Determine if String Halves Are Alike</title>
		<link>https://zxi.mytechroad.com/blog/string/leetcode-1704-determine-if-string-halves-are-alike/</link>
					<comments>https://zxi.mytechroad.com/blog/string/leetcode-1704-determine-if-string-halves-are-alike/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 27 Dec 2020 08:17:51 +0000</pubDate>
				<category><![CDATA[String]]></category>
		<category><![CDATA[counting]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[vowel]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=7856</guid>

					<description><![CDATA[<p>You are given a string&#160;s&#160;of even length. Split this string into two halves of equal lengths, and let&#160;a&#160;be the first half and&#160;b&#160;be the second half.&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-1704-determine-if-string-halves-are-alike/">花花酱 LeetCode 1704. Determine if String Halves Are Alike</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>You are given a string&nbsp;<code>s</code>&nbsp;of even length. Split this string into two halves of equal lengths, and let&nbsp;<code>a</code>&nbsp;be the first half and&nbsp;<code>b</code>&nbsp;be the second half.</p>



<p>Two strings are&nbsp;<strong>alike</strong>&nbsp;if they have the same number of vowels (<code>'a'</code>,&nbsp;<code>'e'</code>,&nbsp;<code>'i'</code>,&nbsp;<code>'o'</code>,&nbsp;<code>'u'</code>,&nbsp;<code>'A'</code>,&nbsp;<code>'E'</code>,&nbsp;<code>'I'</code>,&nbsp;<code>'O'</code>,&nbsp;<code>'U'</code>). Notice that&nbsp;<code>s</code>&nbsp;contains uppercase and lowercase letters.</p>



<p>Return&nbsp;<code>true</code><em>&nbsp;if&nbsp;</em><code>a</code><em>&nbsp;and&nbsp;</em><code>b</code><em>&nbsp;are&nbsp;<strong>alike</strong></em>. Otherwise, return&nbsp;<code>false</code>.</p>



<p><strong>Example 1:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> s = "book"
<strong>Output:</strong> true
<strong>Explanation:</strong>&nbsp;a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.
</pre>



<p><strong>Example 2:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> s = "textbook"
<strong>Output:</strong> false
<strong>Explanation:</strong>&nbsp;a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.
Notice that the vowel o is counted twice.
</pre>



<p><strong>Example 3:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> s = "MerryChristmas"
<strong>Output:</strong> false
</pre>



<p><strong>Example 4:</strong></p>



<pre class="wp-block-preformatted;crayon:false"><strong>Input:</strong> s = "AbCdEfGh"
<strong>Output:</strong> true
</pre>



<p><strong>Constraints:</strong></p>



<ul><li><code>2 &lt;= s.length &lt;= 1000</code></li><li><code>s.length</code>&nbsp;is even.</li><li><code>s</code>&nbsp;consists of&nbsp;<strong>uppercase and lowercase</strong>&nbsp;letters.</li></ul>



<h2><strong>Solution: Counting</strong></h2>



<p>Time complexity: O(n)<br>Space complexity: O(1)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">Python3</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag"># Author: Huahua
class Solution:
  def halvesAreAlike(self, s: str) -&gt; bool:
    def count(s: str) -&gt; int:
      return sum(c in 'aeiouAEIOU' for c in s)
    n = len(s)
    return count(s[:n//2]) == count(s[n//2:])</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/string/leetcode-1704-determine-if-string-halves-are-alike/">花花酱 LeetCode 1704. Determine if String Halves Are Alike</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/string/leetcode-1704-determine-if-string-halves-are-alike/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>花花酱 LeetCode 966. Vowel Spellchecker</title>
		<link>https://zxi.mytechroad.com/blog/hashtable/leetcode-966-vowel-spellchecker/</link>
					<comments>https://zxi.mytechroad.com/blog/hashtable/leetcode-966-vowel-spellchecker/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sun, 30 Dec 2018 20:45:36 +0000</pubDate>
				<category><![CDATA[Hashtable]]></category>
		<category><![CDATA[hashtable]]></category>
		<category><![CDATA[medium]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[vowel]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=4572</guid>

					<description><![CDATA[<p>Problem Given a&#160;wordlist, we want to implement a spellchecker that converts a query word into a correct word. For a given&#160;query&#160;word, the spell checker handles&#8230;</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/hashtable/leetcode-966-vowel-spellchecker/">花花酱 LeetCode 966. Vowel Spellchecker</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2><strong>Problem</strong></h2>



<p>Given a&nbsp;<code>wordlist</code>, we want to implement a spellchecker that converts a query word into a correct word.</p>



<p>For a given&nbsp;<code>query</code>&nbsp;word, the spell checker handles two categories of spelling mistakes:</p>



<ul><li>Capitalization: If the query matches a word in the wordlist (<strong>case-insensitive</strong>), then the query word is returned with the same case as the case in the wordlist.<ul><li>Example:&nbsp;<code>wordlist = ["yellow"]</code>,&nbsp;<code>query = "YellOw"</code>:&nbsp;<code>correct = "yellow"</code></li><li>Example:&nbsp;<code>wordlist = ["Yellow"]</code>,&nbsp;<code>query = "yellow"</code>:&nbsp;<code>correct = "Yellow"</code></li><li>Example:&nbsp;<code>wordlist = ["yellow"]</code>,&nbsp;<code>query = "yellow"</code>:&nbsp;<code>correct = "yellow"</code></li></ul></li><li>Vowel Errors: If after replacing the vowels (&#8216;a&#8217;, &#8216;e&#8217;, &#8216;i&#8217;, &#8216;o&#8217;, &#8216;u&#8217;) of the query word with any vowel individually, it matches a word in the wordlist (<strong>case-insensitive</strong>), then the query word is returned with the same case as the match in the wordlist.<ul><li>Example:&nbsp;<code>wordlist = ["YellOw"]</code>,&nbsp;<code>query = "yollow"</code>:&nbsp;<code>correct = "YellOw"</code></li><li>Example:&nbsp;<code>wordlist = ["YellOw"]</code>,&nbsp;<code>query = "yeellow"</code>:&nbsp;<code>correct = ""</code>&nbsp;(no match)</li><li>Example:&nbsp;<code>wordlist = ["YellOw"]</code>,&nbsp;<code>query = "yllw"</code>:&nbsp;<code>correct = ""</code>&nbsp;(no match)</li></ul></li></ul>



<p>In addition, the spell checker operates under the following precedence rules:</p>



<ul><li>When the query exactly matches a word in the wordlist (<strong>case-sensitive</strong>), you should return the same word back.</li><li>When the query matches a word up to capitlization, you should return the first such match in the wordlist.</li><li>When the query matches a word up to vowel errors, you should return the first such match in the wordlist.</li><li>If the query has no matches in the wordlist, you should return the empty string.</li></ul>



<p>Given some&nbsp;<code>queries</code>, return a&nbsp;list of words&nbsp;<code>answer</code>, where&nbsp;<code>answer[i]</code>&nbsp;is&nbsp;the correct word for&nbsp;<code>query = queries[i]</code>.</p>



<p><strong>Example 1:</strong></p>



<pre class="wp-block-preformatted crayon:false"><strong>Input: </strong>wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"]
<strong>Output: </strong>["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]</pre>



<p><strong>Note:</strong></p>



<ul><li><code>1 &lt;= wordlist.length &lt;= 5000</code></li><li><code>1 &lt;= queries.length &lt;= 5000</code></li><li><code>1 &lt;= wordlist[i].length &lt;= 7</code></li><li><code>1 &lt;= queries[i].length &lt;= 7</code></li><li>All strings in&nbsp;<code>wordlist</code>&nbsp;and&nbsp;<code>queries</code>&nbsp;consist only of&nbsp;<strong>english</strong>&nbsp;letters.</li></ul>



<h2><strong>Solution:&nbsp;HashTable</strong></h2>



<p>Using 3 hashtables: original words, lower cases, lower cases with vowels replaced to &#8220;*&#8221;</p>



<p>Time complexity: O(|W|+|Q|)<br>Space complexity: O(|W|)</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">class Solution {
public:
  vector&lt;string&gt; spellchecker(vector&lt;string&gt;&amp; wordlist, vector&lt;string&gt;&amp; queries) {    
    vector&lt;string&gt; ans;
    unordered_map&lt;string, string&gt; m_org;
    unordered_map&lt;string, string&gt; m_low;
    unordered_map&lt;string, string&gt; m_vow;
    for (const string&amp; w : wordlist) {
      // Original word
      m_org[w] = w;
      // Case-insensitive
      string l = toLower(w); 
      if (!m_low.count(l)) m_low[l] = w; 
      // Vowel-insensitive
      string o = replaceVowels(l);
      if (!m_vow.count(o)) m_vow[o] = w;
    }
    
    for (const string&amp; q : queries) {      
      if (m_org.count(q)) {
        ans.push_back(q);
        continue;
      }
      string l = toLower(q);
      if (m_low.count(l)) {
        ans.push_back(m_low[l]);
        continue;
      }
      
      string o = replaceVowels(l);      
      if (m_vow.count(o)) {
        ans.push_back(m_vow[o]);
        continue;
      }
      ans.push_back(&quot;&quot;);
    }
    return ans;
  }
private:
  string toLower(const string&amp; s) {
    string l(s);
    std::transform(begin(s), end(s), begin(l), ::tolower);
    return l;
  }
  
  string replaceVowels(const string&amp; s) {
    string o(s);
    for (char&amp; c : o)
      if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        c = '*';
    return o;
  }
};</pre>

</div><h2 class="tabtitle">Python3</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">class Solution:
  def spellchecker(self, wordlist, queries):
    org = dict()
    low = dict()
    vow = dict()
    for w in wordlist:
      org[w] = w
      l = w.lower()
      if l not in low: low[l] = w
      v = re.sub(r'[aeiou]', '*', l)
      if v not in vow: vow[v] = w
    ans = []
    for q in queries:
      if q in org: 
        ans.append(q)
        continue
      l = q.lower()
      if l in low:
        ans.append(low[l])
        continue
      v = re.sub(r'[aeiou]', '*', l)
      if v in vow:
        ans.append(vow[v])
        continue
      ans.append(&quot;&quot;)
    return ans</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/hashtable/leetcode-966-vowel-spellchecker/">花花酱 LeetCode 966. Vowel Spellchecker</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/hashtable/leetcode-966-vowel-spellchecker/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
