Trains the technique from
LeetCode 966Vowel SpellcheckerThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A word list is given as entries and a run of lookups as asks, both made of English letters in either case.
Answer each lookup by the first of these rules that finds a match, and where a rule finds several matches, the earliest such entry in entries wins:
a, e, i, o and u: answer that entry;Return the answers in the order the lookups are given.
Example 1
The first lookup matches an entry exactly. The second matches once case is ignored, and the earliest entry doing so is Book. The third differs only in its vowels, again answering Book. The fourth differs only in its vowels from cat. The last matches nothing at all.
Example 2
No entry matches case for case, but folding case away leaves the one entry, so it is the answer with its own spelling kept.
Example 3
The lookup differs from the only entry in a consonant, which no rule forgives, so nothing matches.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def spellchecker(entries: list[str], asks: list[str]) -> list[str]:public String[] spellchecker(String[] entries, String[] asks)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.