mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
65 lines
2.2 KiB
HTML
65 lines
2.2 KiB
HTML
<p>A word is considered <strong>valid</strong> if:</p>
|
|
|
|
<ul>
|
|
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
|
|
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
|
|
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
|
|
<li>It includes <strong>at least</strong> one <strong>consonant</strong>.</li>
|
|
</ul>
|
|
|
|
<p>You are given a string <code>word</code>.</p>
|
|
|
|
<p>Return <code>true</code> if <code>word</code> is valid, otherwise, return <code>false</code>.</p>
|
|
|
|
<p><strong>Notes:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>'a'</code>, <code>'e'</code>, <code>'i'</code>, <code>'o'</code>, <code>'u'</code>, and their uppercases are <strong>vowels</strong>.</li>
|
|
<li>A <strong>consonant</strong> is an English letter that is not a vowel.</li>
|
|
</ul>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">word = "234Adas"</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">true</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>This word satisfies the conditions.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">word = "b3"</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">false</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>The length of this word is fewer than 3, and does not have a vowel.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 3:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">word = "a3$e"</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">false</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>This word contains a <code>'$'</code> character and does not have a consonant.</p>
|
|
</div>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= word.length <= 20</code></li>
|
|
<li><code>word</code> consists of English uppercase and lowercase letters, digits, <code>'@'</code>, <code>'#'</code>, and <code>'$'</code>.</li>
|
|
</ul>
|