Support Wildcard Lookups in an Alexa Skill Invocation Name Registry

Last updated: November 29, 2026

Quick Overview

Design a registry with `add(name)` and `search(pattern)`, where the pattern may contain `.` matching any single character, and search returns whether any added name matches the whole pattern.

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

0

0

0 solved


Design a registry with `add(name)` and `search(pattern)`, where the pattern may contain `.` matching any single character, and search returns whether any added name matches the whole pattern.

A design-a-data-structure screen in Amazon's style, framed around checking whether a proposed voice skill name collides with existing ones when a speech recognizer is unsure about certain letters. The interviewer looks for a trie with a recursive wildcard search and a discussion of worst-case cost.

What the Interviewer Expects
  • Stores names in a trie with end markers
  • Branches over all children on a wildcard
  • Requires a full-length match, not just a prefix
  • Analyzes worst case for patterns with many dots
  • Suggests bucketing by length as an optimization
Key Topics to Cover
tries
DFS
wildcards
design a data structure
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 matching any sequence?
  • How would you return the matching names, not just a boolean?
  • How would you speed up all-dot patterns of a given length?
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 inserts a name (lowercase letters and spaces). search returns True if some stored name has exactly the pattern's length and matches every fixed character, where . matches any one character, ...

High-Level Design

A trie handles fixed characters in O(1)O(1) per step. On ., recurse into every child (skipping the end marker key). The match must end at a node carrying the end marker, otherwise dad joke would wro...


Submit Your Answer
Markdown supported