Return the best match for each query word using exact, case-insensitive, and vowel-insensitive matching rules.
You are given a wordlist and a list of query words. For each query, return the first word from the wordlist that matches according to the following priority:
- Exact match: the query is identical to a word in the wordlist.
- Case-insensitive match: the query matches a word after converting both to lowercase.
- Vowel-error match: the query matches a word after converting both to lowercase and replacing every vowel (
a, e, i, o, u) with a placeholder.
If multiple words could match, return the one that appears earliest in the wordlist. If no word matches, return an empty string.
Build a checker that processes every query independently using these rules.
Input Format
- An array
wordlistof strings. - An array
queriesof strings.
For each query, apply the matching rules in priority order and return the chosen word or an empty string.
Output Format
- Return an array of strings where the
i-th string is the answer forqueries[i].
Constraints
1 <= wordlist.length, queries.length <= 5000- Words contain only English letters.
- Matching must respect the priority: exact > case-insensitive > vowel-insensitive.
- If several words satisfy the same rule, choose the earliest one in
wordlist.
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"]
Explanation
- Exact matches are preferred when available.
- Otherwise, matching ignores case.
- Otherwise, matching ignores vowels.
- If no rule matches, return an empty string.
Example 2
Input
wordlist = ["yellow"], queries = ["YALLOW","yellow","yellOw"]
Output
["yellow","yellow","yellow"]
Explanation
The lowercase-vowel-normalized form of all queries matches yellow, and the exact/case-insensitive matches also resolve to yellow.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.