Given a wordlist, we want to implement a spellchecker that converts a query
word into a correct word.
For a given query word, the spell checker handles two categories of spelling
mistakes:
wordlist = ["yellow"], query = "YellOw":
correct = "yellow"wordlist = ["Yellow"], query = "yellow":
correct = "Yellow"wordlist = ["yellow"], query = "yellow":
correct = "yellow"wordlist = ["YellOw"], query = "yollow":
correct = "YellOw"wordlist = ["YellOw"], query = "yeellow":
correct = "" (no match)
wordlist = ["YellOw"], query = "yllw":
correct = "" (no match)
In addition, the spell checker operates under the following precedence rules:
Given some queries, return a list of words answer, where
answer[i] is the correct word for query = queries[i].
Example 1:
Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"] Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"]
Note:
1 <= wordlist.length <= 50001 <= queries.length <= 50001 <= wordlist[i].length <= 71 <= queries[i].length <= 7wordlist and queries consist only of english letters.