Design Tweet Search
It looks like a database query, find the rows whose text contains these words, but a database is the wrong tool here. You cannot scan billions of tweets on every search, and no B-tree on a text column helps you find a word buried in the middle of a sentence. Search is an information-retrieval problem, and its core data structure is the inverted index, a map from each word to the list of tweets that contain it. Build that well and a query becomes a few list lookups instead of a scan. The second half of the problem is the one that makes it specifically Twitter's. A web search engine can afford to rebuild its index every few minutes. Tweet search cannot, because the point is the live conversation, so the index has to absorb new posts and make them findable within seconds.
- 1 diagram
- 5 sections
- about 42 min
Premium lessonX (Twitter) interview guide
These took digging.
What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.
100 companies. Checked every month.
Unlock all 100 companies$49 a year · less than $1 a week · Cancel anytime
X (Twitter) interview guideKnow what X (Twitter) asks before you walk in.
19 coding · 5 system design · 20 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.