Match Restaurant Name Searches Containing Single-Character Wildcards

Last updated: November 29, 2026

Quick Overview

Implement add(name) and search(pattern) for restaurant names of lowercase letters, where the pattern may contain `.` matching exactly one character. search returns True if any added name matches the whole pattern.

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

0

0

0 solved


Implement add(name) and search(pattern) for restaurant names of lowercase letters, where the pattern may contain `.` matching exactly one character. search returns True if any added name matches the whole pattern.

Seen in Uber technical screens with an Uber Eats search framing. It tests trie construction plus DFS branching on wildcards, and whether you understand the worst-case cost.

What the Interviewer Expects
  • Builds a trie with an end-of-word marker
  • Walks normally for letters and branches into all children for a dot
  • Requires an exact length match by checking the end marker
  • Analyzes worst case for patterns of all dots
  • Keeps search iterative or recursive with clear base cases
Key Topics to Cover
trie
DFS
wildcard matching
backtracking
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
  • Support `*` matching any sequence of characters.
  • How would you speed up patterns that start with many dots?
  • How would you return all matches, capped at 10?
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): store a lowercase name.
  • search(pattern): letters and .; True if a stored name of the same length matches.
  • Many adds and searches interleave....
High-Level Design

Store names in a trie of dicts, with a sentinel key marking the end of a name. Searching is a DFS over (node, index). When the pattern character is a letter, follow that single child if it exists. W...


Submit Your Answer
Markdown supported