Vowel Spellchecker

MediumStringshashing

Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.

Practice this as a mock interviewFree to start, no account needed

Problem

Build a spellchecker. Given a wordlist and a list of queries, map each query to a word using the first rule below that applies: 1. **Exact match**: if the query appears in wordlist with identical casing, return the query itself. 2. **Capitalization**: otherwise, if some word equals the query ignoring case, return the **first** such word in wordlist. 3. **Vowel errors**: otherwise, if some word matches the query when case is ignored and each vowel (a, e, i, o, u) may be replaced by any vowel, return the **first** such word in wordlist. 4. Otherwise return the empty string "". Return an array with one answer per query, in query order. Replacing a vowel never inserts or removes letters, and consonants must match (ignoring case).

Examples

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"]
"Kite" has no exact match, so the first case-insensitive match "KiTe" wins. "keti" matches "KiTe" by swapping vowels. "keet" has an extra vowel in the wrong spot relative to any word and gets "".
Input: wordlist = ["yellow"], queries = ["YellOw"]
Output: ["yellow"]
A case-insensitive match.

Constraints

  • `1 <= wordlist.length, queries.length <= 5000`
  • `1 <= wordlist[i].length, queries[i].length <= 7`
  • All strings consist of English letters only

What the interviewer grades

A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.

More hashing problems