1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/所有元音按顺序排布的最长子字符串 [longest-substring-of-all-vowels-in-order].html
2022-03-29 12:43:11 +08:00

47 lines
1.9 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>当一个字符串满足如下条件时,我们称它是 <b>美丽的</b> </p>
<ul>
<li>所有 5 个英文元音字母(<code>'a'</code> <code>'e'</code> <code>'i'</code> <code>'o'</code> <code>'u'</code>)都必须 <strong>至少</strong> 出现一次。</li>
<li>这些元音字母的顺序都必须按照 <strong>字典序</strong> 升序排布(也就是说所有的 <code>'a'</code> 都在 <code>'e'</code> 前面,所有的 <code>'e'</code> 都在 <code>'i'</code> 前面,以此类推)</li>
</ul>
<p>比方说,字符串 <code>"aeiou"</code> 和 <code>"aaaaaaeiiiioou"</code> 都是 <strong>美丽的</strong> ,但是 <code>"uaeio"</code> <code>"aeoiu"</code> 和 <code>"aaaeeeooo"</code> <strong>不是美丽的</strong> 。</p>
<p>给你一个只包含英文元音字母的字符串 <code>word</code> ,请你返回 <code>word</code><strong>最长美丽子字符串的长度</strong> 。如果不存在这样的子字符串,请返回 <code>0</code> 。</p>
<p><strong>子字符串</strong> 是字符串中一个连续的字符序列。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>word = "aeiaaio<strong>aaaaeiiiiouuu</strong>ooaauuaeiu"
<b>输出:</b>13
<b>解释:</b>最长子字符串是 "aaaaeiiiiouuu" ,长度为 13 。</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>word = "aeeeiiiioooauuu<strong>aeiou</strong>"
<b>输出:</b>5
<b>解释:</b>最长子字符串是 "aeiou" ,长度为 5 。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<b>输入:</b>word = "a"
<b>输出:</b>0
<b>解释:</b>没有美丽子字符串,所以返回 0 。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= word.length <= 5 * 10<sup>5</sup></code></li>
<li><code>word</code> 只包含字符 <code>'a'</code><code>'e'</code><code>'i'</code><code>'o'</code> 和 <code>'u'</code> 。</li>
</ul>