Code Room
CodingMediumcod-g540
Subject TrieLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Design a word dictionary supporting add and wildcard search. Process operations: ["add", word] inserts a lowercase word; ["search", pattern] returns whether any added word matches the pattern, where '.' in the pattern matches any single character (all other characters match literally). The pattern length always equals a stored word's length to match. Return the list of boolean results for the search operations in order. Build a trie and DFS over branches when you hit a '.'.

Implement
wildcard_dictionary(ops: list) → list[bool]
Examples
in[[["add","bad"],["add","dad"],["add","mad"],["search","pad"],["search","bad"],["search",".ad"],["search","b.."]]]out[false,true,true,true]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.