Section 1: Faster Than You Can Type - Problem Understanding & Clarifications
Executive Summary: A prompt that sounds like a weekend project has to become a scope you can defend. We break it into what, who, why and how, then ask the questions that settle the big forks: completion or correction, prefix or infix, how many languages, how personal, how fresh, and who decides what the platform may suggest. You leave with written assumptions, a running example, and the realisation that shapes everything: this is two systems, a read path and a learning path, joined only by an index.
The interviewer reads you one sentence:
"Design the typeahead for a web search engine, like the autocomplete in Google Search. As a user types into the search box, show them the ten most likely completions of what they're typing, updated on every keystroke, fast enough that it feels instant."
Your first thought is probably a trie: a good instinct, and a dangerous place to stop. Most likely means something has to learn what people search for. Every keystroke means one search turns into many requests. Feels instant means you're racing the user's fingers. And like Google means a vast audience, so a suggestion is no longer just data: when the box suggests something, the platform is the one saying it. The trie is in there, inside a very high-rate read system, a pipeline that learns from billions of searches, and a content-policy problem.
Decomposing the Prompt
Before asking anything, map the territory out loud:
- What it does: returns full queries that start with the text typed so far, best first. It completes; it doesn't fix spelling or show results.
- Who uses it: everyone at the search box, many signed out, plenty on a patchy phone connection. The anonymous answer has to be good, because it's the common case.
- Why it exists: fewer keystrokes (latency), better-formed queries (ranking), and discovering what's happening now (freshness). Each pulls the design a different way.
- How it's used: on every character. An average typist leaves roughly a fifth of a second between keystrokes, and a suggestion that lands after the next one is already stale. The deadline is set by a human finger, not a negotiated SLA.
Sign in to continue reading
The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.
Sign in to read the full lesson