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.
16 write-ups
| Title | Difficulty |
|---|---|
| Concurrency Fundamentals Threads, shared state and why races happen, the concurrency toolbox (atomics, locks, semaphores, condition variables, blocking queues) and the three kinds of concurrency questions. | |
| Classic Concurrency Problems The textbook synchronization puzzles interviewers still ask (bounded buffer, print in order, dining philosophers, readers-writers, the bathroom problem, the sleeping barber), what each one teaches and the standard fix. | |
| Deadlocks, Livelocks and Starvation Why threads freeze waiting on each other, the four conditions behind every deadlock, and the fixes interviewers expect: lock ordering, tryLock with timeouts, and detecting cycles in a wait-for graph. | |
| Multithreading Patterns The reusable shapes of multithreaded code: thread pools and futures, fan-out/fan-in, read-write locks, immutability, thread confinement and double-checked locking, with when each one is worth it. | |
| Race Conditions, Locks and Atomics The two shapes of race condition (read-modify-write and check-then-act), how mutexes and atomics fix them, and a step-by-step recipe for making a class thread safe. | |
| Build a Semaphore, Latch and Barrier Build a counting semaphore, a countdown latch and a reusable barrier from one lock and a condition variable, and learn the wait loop behind every blocking primitive. | Medium |
| Design a Bounded Blocking Queue Design a fixed-size FIFO queue that makes producers wait when it is full and consumers wait when it is empty, built from one lock and two condition variables. | Medium |
| Design a Concurrent Hash Map Design a thread-safe hash map from scratch, from one global lock to lock striping, with atomic putIfAbsent and increment, a cheap size counter, and resizing without deadlock. | Hard |
| Design a Connection Pool Design a database connection pool with a size limit, callers that wait in line with a timeout, idle timeouts, dead connections dropped and replaced, and a thread-safe version. | Medium |
| Design a Deadlock Detector Design a lock manager that builds a wait-for graph, detects a deadlock the moment it forms, picks a victim to abort, and hands its locks to the next waiters, safely across threads. | Medium |
| Design a Loading Cache Design a thread-safe cache that loads missing values through a loader, runs one load per key when many threads miss at once, expires entries after a TTL, and never caches failures. | Medium |
| Design a Rule Engine Design a fraud rule engine for card payments, with conditions composed from AND, OR and NOT, velocity rules, the most severe action winning, and safe rule changes under concurrent load. | Medium |
| 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 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 |
| 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 |