|
6 | 6 | import java.util.Set;
|
7 | 7 |
|
8 | 8 | /**
|
| 9 | + * 966. Vowel Spellchecker |
| 10 | + * |
9 | 11 | * Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.
|
10 | 12 | *
|
11 | 13 | * For a given query word, the spell checker handles two categories of spelling mistakes:
|
|
15 | 17 | * Example: wordlist = ["yellow"], query = "YellOw": correct = "yellow"
|
16 | 18 | * Example: wordlist = ["Yellow"], query = "yellow": correct = "Yellow"
|
17 | 19 | * Example: wordlist = ["yellow"], query = "yellow": correct = "yellow"
|
| 20 | + * |
18 | 21 | * Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually,
|
19 | 22 | * it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the
|
20 | 23 | * match in the wordlist.
|
21 | 24 | * Example: wordlist = ["YellOw"], query = "yollow": correct = "YellOw"
|
22 | 25 | * Example: wordlist = ["YellOw"], query = "yeellow": correct = "" (no match)
|
23 | 26 | * Example: wordlist = ["YellOw"], query = "yllw": correct = "" (no match)
|
| 27 | + * |
24 | 28 | * In addition, the spell checker operates under the following precedence rules:
|
25 | 29 | *
|
26 | 30 | * When the query exactly matches a word in the wordlist (case-sensitive), you should return the same word back.
|
27 | 31 | * When the query matches a word up to capitlization, you should return the first such match in the wordlist.
|
28 | 32 | * When the query matches a word up to vowel errors, you should return the first such match in the wordlist.
|
29 | 33 | * If the query has no matches in the wordlist, you should return the empty string.
|
| 34 | + * |
30 | 35 | * Given some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].
|
31 | 36 | *
|
| 37 | + * Example 1: |
| 38 | + * |
| 39 | + * Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"] |
| 40 | + * Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"] |
| 41 | + * |
| 42 | + * Note: |
| 43 | + * |
| 44 | + * 1 <= wordlist.length <= 5000 |
| 45 | + * 1 <= queries.length <= 5000 |
| 46 | + * 1 <= wordlist[i].length <= 7 |
| 47 | + * 1 <= queries[i].length <= 7 |
| 48 | + * All strings in wordlist and queries consist only of english letters. |
| 49 | + * |
32 | 50 | * */
|
33 | 51 |
|
34 | 52 | public class _966 {
|
|
0 commit comments