|
14 | 14 | <p>In an alien language, surprisingly they also use english lowercase letters, but possibly in a different <code>order</code>. The <code>order</code> of the alphabet is some permutation of lowercase letters.</p>
|
15 | 15 |
|
16 | 16 | <p>Given a sequence of <code>words</code> written in the alien language, and the <code>order</code> of the alphabet, return <code>true</code> if and only if the given <code>words</code> are sorted lexicographicaly in this alien language.</p>
|
17 |
| - |
18 | 17 | <p> </p>
|
19 |
| - |
20 |
| -<div> |
21 | 18 | <p><strong>Example 1:</strong></p>
|
22 | 19 |
|
23 | 20 | <pre>
|
24 |
| -<strong>Input: </strong>words = <span id="example-input-1-1">["hello","leetcode"]</span>, order = <span id="example-input-1-2">"hlabcdefgijkmnopqrstuvwxyz"</span> |
25 |
| -<strong>Output: </strong><span id="example-output-1">true</span> |
26 |
| -<strong>Explanation: </strong><span id="example-output-1">As 'h' comes before 'l' in this language, then the sequence is sorted.</span> |
| 21 | +<strong>Input:</strong> words = ["hello","leetcode"], order = "hlabcdefgijkmnopqrstuvwxyz" |
| 22 | +<strong>Output:</strong> true |
| 23 | +<strong>Explanation: </strong>As 'h' comes before 'l' in this language, then the sequence is sorted. |
27 | 24 | </pre>
|
28 | 25 |
|
29 |
| -<div> |
30 | 26 | <p><strong>Example 2:</strong></p>
|
31 | 27 |
|
32 | 28 | <pre>
|
33 |
| -<strong>Input: </strong>words = <span id="example-input-2-1">["word","world","row"]</span>, order = <span id="example-input-2-2">"worldabcefghijkmnpqstuvxyz"</span> |
34 |
| -<strong>Output: </strong><span id="example-output-2">false</span> |
35 |
| -<strong>Explanation: </strong><span id="example-output-1">As 'd' comes after 'l' in this language, then words[0] > words[1], hence the sequence is unsorted.</span> |
| 29 | +<strong>Input:</strong> words = ["word","world","row"], order = "worldabcefghijkmnpqstuvxyz" |
| 30 | +<strong>Output:</strong> false |
| 31 | +<strong>Explanation: </strong>As 'd' comes after 'l' in this language, then words[0] > words[1], hence the sequence is unsorted. |
36 | 32 | </pre>
|
37 | 33 |
|
38 |
| -<div> |
39 | 34 | <p><strong>Example 3:</strong></p>
|
40 | 35 |
|
41 | 36 | <pre>
|
42 |
| -<strong>Input: </strong>words = <span id="example-input-3-1">["apple","app"]</span>, order = <span id="example-input-3-2">"abcdefghijklmnopqrstuvwxyz"</span> |
43 |
| -<strong>Output: </strong><span id="example-output-3">false |
44 |
| -</span><strong>Explanation: </strong>The first three characters "app" match, and the second string is shorter (in size.) According to lexicographical rules "apple" > "app", because 'l' > '∅', where '∅' is defined as the blank character which is less than any other character (<a href="https://en.wikipedia.org/wiki/Lexicographical_order" target="_blank">More info</a>). |
| 37 | +<strong>Input:</strong> words = ["apple","app"], order = "abcdefghijklmnopqrstuvwxyz" |
| 38 | +<strong>Output:</strong> false |
| 39 | +<strong>Explanation: </strong>The first three characters "app" match, and the second string is shorter (in size.) According to lexicographical rules "apple" > "app", because 'l' > '∅', where '∅' is defined as the blank character which is less than any other character (<a href="https://en.wikipedia.org/wiki/Lexicographical_order" target="_blank">More info</a>). |
45 | 40 | </pre>
|
46 | 41 |
|
47 | 42 | <p> </p>
|
| 43 | +<p><strong>Constraints:</strong></p> |
48 | 44 |
|
49 |
| -<p><strong>Note:</strong></p> |
50 |
| - |
51 |
| -<ol> |
| 45 | +<ul> |
52 | 46 | <li><code>1 <= words.length <= 100</code></li>
|
53 | 47 | <li><code>1 <= words[i].length <= 20</code></li>
|
54 | 48 | <li><code>order.length == 26</code></li>
|
55 |
| - <li>All characters in <code>words[i]</code> and <code>order</code> are english lowercase letters.</li> |
56 |
| -</ol> |
57 |
| -</div> |
58 |
| -</div> |
59 |
| -</div> |
| 49 | + <li>All characters in <code>words[i]</code> and <code>order</code> are English lowercase letters.</li> |
| 50 | +</ul> |
60 | 51 |
|
61 | 52 | ### Related Topics
|
62 | 53 | [[Hash Table](https://github.com/openset/leetcode/tree/master/tag/hash-table/README.md)]
|
0 commit comments