|
1 | 1 | # [966.Vowel Spellchecker][title] |
2 | 2 |
|
3 | | -> [!WARNING|style:flat] |
4 | | -> This question is temporarily unanswered if you have good ideas. Welcome to [Create Pull Request PR](https://github.com/kylesliu/awesome-golang-algorithm) |
5 | | -
|
6 | 3 | ## Description |
7 | 4 |
|
| 5 | +Given a `wordlist`, we want to implement a spellchecker that converts a query word into a correct word. |
| 6 | + |
| 7 | +For a given `quer` word, the spell checker handles two categories of spelling mistakes: |
| 8 | + |
| 9 | +- Capitalization: If the query matches a word in the wordlist (**case-insensitive**), then the query word is returned with the same case as the case in the wordlist. |
| 10 | + |
| 11 | + - Example: `wordlist = ["yellow"]`, `query = "YellOw"`: `correct = "yellow"` |
| 12 | + - Example: `wordlist = ["Yellow"]`, `query = "yellow"`: `correct = "Yellow"` |
| 13 | + - Example: `wordlist = ["yellow"]`, `query = "yellow"`: `correct = "yellow"` |
| 14 | + |
| 15 | +- Vowel Errors: If after replacing the vowels `('a', 'e', 'i', 'o', 'u')` of the query word with any vowel individually, it matches a word in the wordlist (**case-insensitive**), then the query word is returned with the same case as the match in the wordlist. |
| 16 | + |
| 17 | + - Example: `wordlist = ["YellOw"]`, `query = "yollow"`: `correct = "YellOw"` |
| 18 | + - Example: `wordlist = ["YellOw"]`, `query = "yeellow"`: `correct = ""` (no match) |
| 19 | + - Example: `wordlist = ["YellOw"]`, `query = "yllw"`: `correct = ""` (no match) |
| 20 | + |
| 21 | +In addition, the spell checker operates under the following precedence rules: |
| 22 | + |
| 23 | +- When the query exactly matches a word in the wordlist (**case-sensitive**), you should return the same word back. |
| 24 | +- When the query matches a word up to capitlization, you should return the first such match in the wordlist. |
| 25 | +- When the query matches a word up to vowel errors, you should return the first such match in the wordlist. |
| 26 | +- If the query has no matches in the wordlist, you should return the empty string. |
| 27 | + |
| 28 | +Given some `queries`, return a list of words `answer`, where `answer[i]` is the correct word for `query = queries[i]`. |
| 29 | + |
8 | 30 | **Example 1:** |
9 | 31 |
|
10 | 32 | ``` |
11 | | -Input: a = "11", b = "1" |
12 | | -Output: "100" |
| 33 | +Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"] |
| 34 | +Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"] |
13 | 35 | ``` |
14 | 36 |
|
15 | | -## 题意 |
16 | | -> ... |
| 37 | +**Example 2:** |
17 | 38 |
|
18 | | -## 题解 |
19 | | - |
20 | | -### 思路1 |
21 | | -> ... |
22 | | -Vowel Spellchecker |
23 | | -```go |
24 | 39 | ``` |
25 | | - |
| 40 | +Input: wordlist = ["yellow"], queries = ["YellOw"] |
| 41 | +Output: ["yellow"] |
| 42 | +``` |
26 | 43 |
|
27 | 44 | ## 结语 |
28 | 45 |
|
|
0 commit comments