Section 1: Everyone Can Write the Query - Problem Understanding & Clarifications
Executive Summary: This section covers the first ten minutes of a Staff interview on the home feed of a photo-sharing app. We split the prompt into what, who, why and how, and find a hidden verb (rank) and a hidden noun (the materialized feed). We meet the two customers, the author and the viewer, who run on different clocks. We name the two traps, the Timeline Joiner and the Broadcaster, each killed by one number. Then six clarifying questions, written assumptions, and the running example: Maya, her friend Dev, and @luna_sings with 80 million followers.
The interviewer reads the prompt off a card:
"Design the home feed for a photo-sharing social app, like Instagram's feed or Facebook's News Feed. Users follow other accounts and post photos with captions. When someone opens the app, they see a ranked, infinitely scrollable feed of recent posts from the accounts they follow."
Every candidate in the building can write the first version of this:
SELECT * FROM posts
WHERE author_id IN (/* the 200 accounts I follow */)
ORDER BY created_at DESC
LIMIT 20;
That query is correct. It's also the first thing the interviewer expects you to throw away. Your job in these ten minutes is to show you know why, before you draw a box.
Decomposing the Prompt
Start with the four questions you'd ask of any system.
- What it does: three verbs you can see. Post, follow, read the feed. A fourth hides in the word "ranked": rank. And there's a hidden noun, the materialized feed: a precomputed list of post IDs per user, ready before they open the app. Whether that list exists, and for whom, is the main design decision of the hour.
- Who uses it: two customers, covered in the next section. The person posting and the person scrolling want different things.
- Why it exists: to bring people back. A feed that's slow, stale or full of things they don't care about loses opens, and opens are the business.
- How it's used: a phone app. You open it, see the first page, scroll a bit, close it. Then you do that again, about 10 times a day.
This diagram shows the prompt split four ways, with the hidden verb and noun called out.
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