Low-level design
Object-oriented design for interviews: the framework, design principles and patterns, concurrency, and problem breakdowns you can practice in the code runner.
Object-oriented design for interviews: the framework, design principles and patterns, concurrency, and problem breakdowns you can practice in the code runner.
55 write-ups
| Title | Difficulty |
|---|---|
| Design a Traffic-Light Intersection Design a thread-safe controller for a two-road intersection: cars from four directions, one green road at a time, switching only when needed, and no crashes or deadlocks. | Easy |
| Design an API Aggregator Design a flight price aggregator that queries many providers in parallel behind one interface, enforces a deadline, returns partial results with per-provider status, and skips providers that keep failing. | Medium |
| Design an ATM Design an ATM with card and PIN sessions as a State pattern, card blocking after wrong PINs, all-or-nothing cash dispensing by note, deposits, and safe concurrent withdrawals from one account. | Medium |
| Design an In-Process MapReduce Design a multithreaded MapReduce inside one process: split the input, map on worker threads, shuffle pairs into partitions by key, reduce in parallel, with word count and an inverted index as jobs. | Medium |
| Design an LRU Cache Design a fixed-size cache with a pluggable eviction policy: LRU with a hash map and a doubly linked list, LFU with LRU tie-breaking in O(1), and a thread-safe sharded version. | Medium |
| Design an Online Auction System Design an online auction system with bid rules, auctions that close exactly at their end time through a min-heap of deadlines, per-bidder winnings, and safe concurrent bidding with per-auction locks. | Medium |
| Design an Order Matching Engine Design a stock exchange's order book and matching engine with limit and market orders, price-time priority, partial fills and cancels, matched in batch first and then as a stream. | Hard |
| Design an Underground System Design a metro tap-in and tap-out system that tracks riders between stations and answers the average travel time of any route in constant time, with the rules for double taps and missing check-ins. | Medium |
| Design Concurrent Bank Transfers Design a bank where many threads move money between accounts at once, with per-account locks taken in a fixed order so transfers never deadlock and the total is always conserved. | Medium |
| Design Dining Philosophers Let n philosophers share n forks with no deadlock and no starvation, from why "left fork first" gets stuck to a fair waiter that hands out both forks at once. | Medium |
| Design Movie Ticket Booking Design a BookMyShow-style booking system with shows, seat maps, temporary seat holds that expire, confirm and cancel, and safe booking when many users want the same seat. | Medium |
| Design the Sleeping Barber Design a thread-safe barbershop where the barber sleeps when nobody waits, arriving customers take a waiting chair or leave when the shop is full, and each customer waits for their own haircut. | Medium |
| Design the Unisex Bathroom Design a thread-safe shared bathroom that holds one gender at a time, never more than its capacity, and lets everyone in eventually, using a lock, a condition variable and a ticket line. | Medium |
| Implement a Promise / Future Build a thread-safe promise that settles once, wakes blocked readers with timeouts, runs then-callbacks exactly once, and combines results with allOf and anyOf, like a small CompletableFuture. | Medium |
| Implement a Read-Write Lock Build a read-write lock from a mutex and a condition variable, with writer preference so writers never starve, try methods, and the upgrade, reentrancy and fairness follow-ups. | Medium |