Skip to main content
Back to problems
Leetcode
Medium
Hash Maps
Strings
Google
Microsoft
Vowel Spellchecker

Return the best match for each query word using exact, case-insensitive, and vowel-insensitive matching rules.

Acceptance 0%
Problem Statement

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:

  1. Exact match: the query is identical to a word in the wordlist.
  2. Case-insensitive match: the query matches a word after converting both to lowercase.
  3. 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 wordlist of strings.
  • An array queries of 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 for queries[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.
Examples
Sample cases returned by the problem API.

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.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.