Lesson 03

Problems Not in This Book

Closing

No interviewer promises you one of these twenty. A new question is seldom new, though: most of it is a problem you have worked, and one part of it is not.

Mapping it takes three questions: which problem has the same shape, which blocks it reuses, and what is actually new. The third is the one that matters, because the new part is where your deep dive should go. Seven common questions show how it works.

Three Questions, After Scope

The mapping comes after Scope, never before, because the requirements decide which problem it resembles. Then you say all three parts aloud. On ride hailing, the line could be: "This has the shape of a nearby search over points that move, and it reuses a hold like a hotel booking's. What's new is the matching, so that's where I'd spend the deep dive."

The way this goes wrong is stopping at the first part. "This is just the news feed" is a claim the interviewer will test on the part that is not. First Design still comes first, drawn for this question and its numbers.

The move, three steps
Scope firstrequirements and numbers
→
Shape and blockssaid aloud
→
What is newwhere the deep dive goes

Places and Things That Move

Maps and routing start from Proximity Service, Chapter 16, whose cells answer what is near. Search Autocomplete, Chapter 9, gives the split of a slow offline path from a fast served one, and Chapter 2's The Edge: CDNs as a Black Box serves the map images. What is new is the road graph. Plain shortest-path search is too slow across a continent, so shortcuts are precomputed to make a query fast, and live traffic keeps changing how long each road takes, so their costs have to be refreshed while queries run. The search itself is in Computer Science Deep Dive, Chapter 8.

Ride hailing starts from Proximity Service's own curveball, points that report every few seconds, which turns the index write-heavy. Hotel Reservation, Chapter 23, gives the rule: a driver goes to one rider, as a room is sold once. Chapter 5's Leases, Locks and Fencing gives the offer that times out. What is new is the matching itself, and a trip's state carried across a long flow that can fail at any step.

Content and Mail

Photo sharing takes News Feed, Chapter 17, Object Storage, Chapter 22, the edge from Chapter 2, and Video Streaming's upload pipeline, Chapter 19, at a far smaller size. Almost nothing is new, and saying so is the strong move. The hard part stays the feed's fan-out, and sizes are what you re-estimate.

An email service takes the outside parties from Notification System, Chapter 15, and offline delivery and sync across devices from Chat, Chapter 18. Its key hashes the mailbox and sorts by time, the compound key in Chapter 3's Range, Hash and Directory. Attachments are objects, as in Chapter 22, and search inside a mailbox is the keyword index from RAG Chatbot, Chapter 26. What is new is that other people's servers can refuse you, so sending reputation, how far they trust your server and your domain, and spam filtering are a design problem. Mail is also kept for years.

Live Edits and Strict Order

Collaborative editing is File Sync's own curveball, in Chapter 20, which calls it another product. Chat, Chapter 18, gives the stateful connections and a number per conversation, here one per document. Chapter 4's Concurrent Writes and Conflicts defines the CRDT, a data type whose merge is part of the type, works it on counts and sets, and names text types in one line. What is new is merging at the speed of typing, where the choice is between a server that orders every edit and a data type that merges without one. Text is a much harder type than a count.

A stock exchange takes the replicated log and commit rule from Message Queue, Chapter 14, and turns Digital Wallet's one writer per account, Chapter 25, into one writer per traded symbol, or per group of symbols. What is new is strict order with a deterministic replay, meaning the same log always produces the same trades, and a budget where every trip counts. A round trip between zones takes 1 to 2 milliseconds. A memory access takes about 100 nanoseconds. So one round trip costs 10,000 memory accesses or more, the matching stays inside one machine, and the commit rule's trip is the one cost left to defend.

Running Other People's Code

An online judge is a work queue, from Chapter 6's Queues, Logs and Pub-Sub, with Video Streaming's workers that may run twice. Rate Limiter, Chapter 11, holds down submissions, and Real-Time Leaderboard, Chapter 8, runs a contest's standings. What is new is that every job is hostile code from a stranger, so isolation and limits on time and memory are the deep dive. A container shares the host's kernel, so one kernel exploit can reach the host and every other job, and hostile code usually gets a stronger wall: a sandboxed runtime or a small virtual machine. How containers isolate a process, and where that stops, is in Docker Deep Dive and Linux Deep Dive.

Seven questions and their nearest problems
Maps and routing→Proximity Service, Search Autocomplete
Ride hailing→Proximity Service, Hotel Reservation
Photo sharing→News Feed, Object Storage
An email service→Notification System, Chat
Collaborative editing→File Sync, Chat
A stock exchange→Message Queue, Digital Wallet
An online judge→A work queue, Video Streaming

When Nothing Maps

Some questions have no near neighbour, and the method still runs. Fall back on the blocks: API and data before boxes, the store chosen from the access pattern, a design that is correct at small scale, and the interviewer's probes for the rest. Say that you have not seen it. That candour costs nothing, because the round was never a test of having seen it.

Use these seven as the blind attempts in the plan from lesson 1. None has a level section of its own, so mark each against the section of its nearest problem.

Misconceptions
  • "If it isn't in the book I can't prepare for it." The moves transfer. These seven common questions have only one or two parts you have not worked.
  • "I should name the nearest problem right away." Before Scope, you do not know which it is. A question that sounds like a feed can have requirements that make it a chat.
  • "Mapping means reusing the old design." The mapping says where to start and where the new part is. First Design is still drawn for this question and its numbers.
  • "The new part must be big." Sometimes, as with photo sharing, almost nothing is new. Saying so with the sizes shows more judgement than inventing a hard part.
  • "An unfamiliar question is a bad sign." It shows the method with no memorised answer in the way, and the method is what the notes record.
Why It Matters
  • Map after Scope, aloud, in three parts: the shape, the blocks and what is new.
  • Send the deep dive to what is new, and say so before the interviewer picks.
  • Re-estimate from the new question's own numbers, even when the shape is familiar.
  • Fall back on access patterns and a small correct design when nothing maps, and say that you are doing it.
RelatedTaking a Probe which still runs on a new questionAPI and Data Before Boxes the fallbackA Practice Plan these seven as blind attemptsComputer Science Deep Dive Chapter 8, for shortest pathsDocker Deep Dive how a container isolates, and where that stopsLinux Deep Dive the kernel underneath

Knowledge Check

Ride hailing has to give each driver to one rider at a time. Which problem in this book has that rule?

  • News Feed, where one post goes out to many readers
  • Chat, where one number orders every conversation
  • Hotel Reservation, where one room is sold once
  • Rate Limiter, where many servers share one count

You are asked for photo sharing, and the mapping leaves almost nothing new. Where does that leave the deep dive?

  • On the feed's fan-out, saying that little else is new, with the sizes
  • On the image format, which then has to carry a deep dive of its own
  • On the object store, since these files are too small for one to serve
  • Nowhere, because a question with nothing new gives you no way to do well

When do you say which problem a new question resembles?

  • As soon as you hear it, to show that you recognise it
  • After Scope, once the requirements have set its shape
  • After First Design, once the boxes show what it is
  • Only if the interviewer asks you what it reminds you of

You say "this is just the news feed" and stop there. What does that cost you?

  • The interviewer may not know that problem and cannot follow you
  • It commits you to drawing the final design with no first design
  • It uses up the minutes that the estimates had in the Scope phase
  • They test the claim on the part of the question that is not a feed

No problem you know comes close to the question. What do you do?

  • Take the closest problem you know and draw its design as it stands
  • Ask the interviewer for another question that you can map to a problem
  • Say so, then go from the API and data to a small correct design
  • Start on the hardest-looking part, since that is what will be probed

You got correct