Design a Top-K and Leaderboard System
A Top-K system counts events per item and keeps a ranked list of the K biggest, for example the 10 or 100 most-played songs. On one machine that's a hash map and a heap. It gets hard at a few hundred thousand events a second, and harder again when the window slides, because counts have to go down as old plays age out. The same machinery sits under a family of prompts. Top URLs over the last hour, day and week is this problem with a far bigger set of keys. A gaming leaderboard ranks scores instead of counts and adds "what's my rank?". A live viewer counter is one item with an enormous count. This lesson builds the song chart end to end, then takes the URL, leaderboard and live counter versions as deep dives.
MicrosoftPremium lesson · System design round
The Microsoft design, worked end to end.
- The API and data modelSystem design · Signature problem
- The design, drawn out2 diagrams
- 6 deep divesWith the tradeoffs
$49 a year · all 107 companies · instant access
1,382 Microsoft interview reports · guide updated
Microsoft interview guideKnow what Microsoft asks before you walk in.
21 coding · 9 system design · 24 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.