Restaurant Search Autocomplete Ranked by Order Volume

Last updated: November 29, 2026

Quick Overview

Build an autocomplete for store search: record order counts for restaurant names and, for any typed prefix, return the top k names by order volume, with fast queries even when the catalog is large.

DoorDash
Coding & Algorithms
Software Engineer
DoorDash
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Build an autocomplete for store search: record order counts for restaurant names and, for any typed prefix, return the top k names by order volume, with fast queries even when the catalog is large.

Search on DoorDash is a major entry point, and typeahead must respond on every keystroke. This trie question checks whether you cache top-k at each node to make queries O(prefix length), and whether you reason about update cost and the assumption that volumes only grow.

What the Interviewer Expects
  • Build a case-insensitive trie over names
  • Store a small sorted top-k list at each node
  • Update every node on the name's path when its volume changes
  • Answer a query by walking the prefix only
  • Explain the read-heavy trade-off and memory cost
Key Topics to Cover
tries
prefix search
top-k caching
read vs write trade-offs
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
  • What breaks if order volume can decrease (for example, a decayed 7-day count)?
  • How would you support typos or matching on any word in the name?
  • How would you shard this across a fleet and personalize results by location?
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
  • record_orders(name, count) adds orders to a restaurant (counts only increase).
  • suggest(prefix) returns up to k names whose lowercase form starts with the prefix, by volume descending, ties by ...
High-Level Design

Each trie node stores top, a list of at most k (-volume, name) pairs. On an update, walk the name's characters; at each node remove any stale entry for this name, add the new pair, sort, and trunc...


Submit Your Answer
Markdown supported