Contact Lookup Trie With Single-Character Wildcard Queries

Last updated: November 29, 2026

Quick Overview

Design a structure for an Outlook contact picker that supports adding names and searching for a name where each "." in the query matches exactly one arbitrary character.

Microsoft
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Design a structure for an Outlook contact picker that supports adding names and searching for a name where each "." in the query matches exactly one arbitrary character.

A Microsoft technical screen design-plus-coding question themed on people search in Outlook and Teams. The interviewer checks that you choose a trie, write a clean recursive search that only branches on wildcards, and can reason about the worst case.

What the Interviewer Expects
  • Use a trie with an end-of-word marker
  • Branch over all children only on a wildcard character
  • Return early on the first successful branch
  • State insertion and query complexity, including the wildcard worst case
  • Mention memory trade-offs of dict children versus arrays
Key Topics to Cover
trie
DFS
wildcard matching
data structure design
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you add a "*" wildcard that matches any run of characters?
  • How would you return all matching names, ranked by how often the user emails them?
  • How would you support case-insensitive and accent-insensitive matching?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

add(name) stores a name. search(pattern) returns True if some stored name has exactly the pattern's length and matches it, where . matches any single character and every other character must mat...

High-Level Design

A trie keyed by character, with a sentinel key (None, which can never collide with a real character) marking the end of a name. Literal characters follow one edge, so a wildcard-free search costs th...


Submit Your Answer
Markdown supported