Skip to content

Commit ec8112c

Browse files
refactor 966
1 parent 1f49d7d commit ec8112c

File tree

1 file changed

+18
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+18
-0
lines changed

src/main/java/com/fishercoder/solutions/_966.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.util.Set;
77

88
/**
9+
* 966. Vowel Spellchecker
10+
*
911
* Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.
1012
*
1113
* For a given query word, the spell checker handles two categories of spelling mistakes:
@@ -15,20 +17,36 @@
1517
* Example: wordlist = ["yellow"], query = "YellOw": correct = "yellow"
1618
* Example: wordlist = ["Yellow"], query = "yellow": correct = "Yellow"
1719
* Example: wordlist = ["yellow"], query = "yellow": correct = "yellow"
20+
*
1821
* Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually,
1922
* it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the
2023
* match in the wordlist.
2124
* Example: wordlist = ["YellOw"], query = "yollow": correct = "YellOw"
2225
* Example: wordlist = ["YellOw"], query = "yeellow": correct = "" (no match)
2326
* Example: wordlist = ["YellOw"], query = "yllw": correct = "" (no match)
27+
*
2428
* In addition, the spell checker operates under the following precedence rules:
2529
*
2630
* When the query exactly matches a word in the wordlist (case-sensitive), you should return the same word back.
2731
* When the query matches a word up to capitlization, you should return the first such match in the wordlist.
2832
* When the query matches a word up to vowel errors, you should return the first such match in the wordlist.
2933
* If the query has no matches in the wordlist, you should return the empty string.
34+
*
3035
* Given some queries, return a list of words answer, where answer[i] is the correct word for query = queries[i].
3136
*
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+
*
3250
* */
3351

3452
public class _966 {

0 commit comments

Comments
 (0)