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)/验证外星语词典 [verifying-an-alien-dictionary].html
2022-03-29 12:43:11 +08:00

39 lines
1.8 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>某种外星语也使用英文小写字母,但可能顺序 <code>order</code> 不同。字母表的顺序(<code>order</code>)是一些小写字母的排列。</p>
<p>给定一组用外星语书写的单词 <code>words</code>,以及其字母表的顺序 <code>order</code>,只有当给定的单词在这种外星语中按字典序排列时,返回 <code>true</code>;否则,返回 <code>false</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>words = ["hello","leetcode"], order = "hlabcdefgijkmnopqrstuvwxyz"
<strong>输出:</strong>true
<strong>解释:</strong>在该语言的字母表中,'h' 位于 'l' 之前,所以单词序列是按字典序排列的。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>words = ["word","world","row"], order = "worldabcefghijkmnpqstuvxyz"
<strong>输出:</strong>false
<strong>解释:</strong>在该语言的字母表中,'d' 位于 'l' 之后,那么 words[0] > words[1],因此单词序列不是按字典序排列的。</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>words = ["apple","app"], order = "abcdefghijklmnopqrstuvwxyz"
<strong>输出:</strong>false
<strong>解释:</strong>当前三个字符 "app" 匹配时,第二个字符串相对短一些,然后根据词典编纂规则 "apple" > "app",因为 'l' > '∅',其中 '∅' 是空白字符,定义为比任何其他字符都小(<a href="https://baike.baidu.com/item/%E5%AD%97%E5%85%B8%E5%BA%8F" target="_blank">更多信息</a>)。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= words.length <= 100</code></li>
<li><code>1 <= words[i].length <= 20</code></li>
<li><code>order.length == 26</code></li>
<li>在 <code>words[i]</code> 和 <code>order</code> 中的所有字符都是英文小写字母。</li>
</ul>