Scenario
Design a LeetCode-like online coding practice platform that also has a global leaderboard (e.g., Top K users by score) and can show a user’s rank.
Functional requirements
-
Users can:
-
Browse problems.
-
Submit code for a problem in a chosen language.
-
Receive verdicts (Accepted/Wrong Answer/Time Limit, etc.) and runtime/memory stats.
-
The system maintains a
leaderboard
:
-
Score model is flexible (e.g., points per solved problem, bonus for difficulty, penalties for wrong submissions).
-
Support queries:
-
GetTopK(k)
(global and optionally per region/time window).
-
GetUserRank(userId)
.
Non-functional requirements
-
High throughput during peaks (many submissions at once).
-
Low-latency reads for Top K leaderboard.
-
Correctness and anti-cheat considerations.
-
Observability: be able to identify bottlenecks and scale the right components.
Deliverables
-
High-level architecture and main services.
-
Data model (what is stored where).
-
APIs for submission + leaderboard queries.
-
How leaderboard updates are computed and served efficiently.
-
Identify likely bottlenecks and how you’d improve them.