Coding Problems
58 guides
What each machine coding and debugging problem tests, and how to approach it.
Hotel Room Booking SystemA hotel booking system low level design interview problem you solve in a real backend repository. Practice date-range overlap checks, half-open check-in/check-out intervals, and cancellation rules — against failing tests, not a whiteboard.Machine coding and LLD3 min readWith code exampleLoyalty Points and Tier Management System Coding ProblemA loyalty points system LLD interview problem you solve in a real backend repository. Practice FIFO point-lot expiry, oldest-first redemption, tier recalculation, and idempotent earn events — with failing tests. Free to try.Machine coding and LLD3 min readWith code exampleDistributed Job SchedulerA distributed job scheduler system design interview problem made concrete in a real repository. Practice single-owner leases, exactly-once execution, worker crash recovery, and claim races — against failing tests.Machine coding and LLD3 min readWith code exampleFlash Sale Inventory SystemA flash sale system design interview problem in a real backend repo: prevent overselling when thousands of buyers race the same stock. Practice atomic check-and-decrement, per-item locking, and purchase integrity — against failing tests.Machine coding and LLD3 min readWith code exampleFile Upload DeduplicationA file upload system design interview problem in a real backend repo: multipart upload finalization, checksum-based deduplication, and safe cleanup under concurrency — solved against failing tests.Machine coding and LLD3 min readWith code exampleFood Delivery Order Status Tracker Coding ProblemA food delivery order tracking system LLD problem you solve in a real backend repository. Practice order lifecycle state machines, legal transitions, cancellation rules, and status history — against failing tests.Machine coding and LLD3 min readWith code exampleE-Commerce Coupon EngineA coupon system low level design interview problem in a real backend repository. Practice eligibility rules, stacking, discount caps, and idempotent redemption in a checkout flow — against failing tests.Machine coding and LLD3 min readWith code exampleWallet Transaction and Refund System Coding ProblemA wallet system design interview problem you solve in a real backend repository. Practice ledger consistency, idempotent credits and debits, refund caps, and balance invariants — the payment wallet LLD round, with failing tests.Machine coding and LLD3 min readWith code exampleMessage Queue ConsumerA message queue consumer interview problem in a real backend repository. Practice at-least-once delivery, idempotent message effects, exponential backoff retries, and dead-letter queues — against failing tests.Machine coding and LLD3 min readWith code exampleURL ShortenerThe URL shortener interview question as a real backend repository: alias uniqueness, per-user quotas, expiry-aware resolution, and owner-only deletion — solved against failing tests, not on a whiteboard.Machine coding and LLD3 min readWith code exampleAuction Bidding SystemAn auction bidding system interview problem in a real backend repository. Practice race-safe bid placement, per-auction critical sections, and closing an auction exactly once while bids are still arriving.Machine coding and LLD3 min readWith code exampleMarketplace Escrow SystemA marketplace escrow system interview problem in a real backend repository. Practice concurrency-safe held-balance release, terminal-state guards, deadline-based auto-release, and ledger reconciliation.Machine coding and LLD3 min readWith code exampleFeature Flag SystemA feature flag system interview problem in a real backend repository. Practice priority-ordered rule evaluation, deterministic percentage bucketing, environment isolation, and kill-switch precedence.Machine coding and LLD3 min readWith code exampleSubscription BillingA subscription billing system interview problem in a real backend repository. Practice mid-cycle proration math, idempotent invoicing, subscription lifecycle states, and dunning transitions — against failing tests.Machine coding and LLD3 min readWith code exampleRide Booking Driver Matching Coding ProblemThe ride booking / driver matching interview problem in a real backend repository. Practice candidate selection, deterministic assignment with tie-breaks, and release-on-cancel — the Uber/Ola-style LLD round.Machine coding and LLD3 min readWith code exampleNotification SystemA notification system design interview problem in a real backend repository. Practice channel preferences, quiet-hours suppression, and idempotent delivery that survives retries — free to try, no signup to read.Machine coding and LLD3 min readWith code exampleCalendar Slot BookingA shared calendar slot booking interview problem in a real backend repository. Practice multi-attendee booking, per-owner ordered locking to prevent deadlock, and race-free double-booking checks.Machine coding and LLD3 min readWith code exampleInventory Stock ReservationAn inventory reservation system interview problem in a real backend repository. Practice reserved-versus-available accounting, duplicate line merging, all-or-nothing rollback, and cancel/confirm stock transitions.Machine coding and LLD3 min readWith code exampleAirflow DAG Dependency & Idempotent Load Coding ProblemA data engineering interview problem in a real Python repository: fix a scheduler that runs tasks out of dependency order and double-counts on retry. Practice topological execution and idempotent loads against failing tests.Machine coding and LLD3 min readWith code examplePandas Join Fan-out & Deduplication Coding ProblemA data engineering interview problem in a real Python repository: a many-to-many pandas join inflates row counts and a dedup on the wrong subset hides it. Fix the join grain against failing tests.Machine coding and LLD3 min readWith code exampleSQL Window Function Partitioning Coding ProblemA data engineering interview problem in a real repository over SQLite: a ROW_NUMBER() with the wrong partition/order keeps the wrong row and a running-total frame is off. Fix the window functions against failing tests.Machine coding and LLD3 min readWith code exampleIncremental CDC Merge & Late-arriving Data Coding ProblemA data engineering interview problem in a real Python repository: an incremental watermark load drops late-arriving records and keeps a stale version on merge. Fix the incremental/CDC merge against failing tests.Machine coding and LLD3 min readWith code exampleData Leakage in a Feature Pipeline Coding ProblemAn ML engineering interview problem in a real Python repository: a preprocessing pipeline fits on the whole dataset before the split and a target-derived feature leaks the label. Fix the leakage against structural, bounded tests.Machine coding and LLD3 min readWith code exampleModel Serving Prediction API Contract Coding ProblemAn ML engineering interview problem in a real Python repository: a FastAPI /predict endpoint whose Pydantic schema and input validation do not match the contract. Fix the serving API against TestClient assertions.Machine coding and LLD3 min readWith code exampleML Metric Computation & Pooling Coding ProblemAn ML engineering interview problem in a real Python repository: a precision/recall miscompute and per-batch averaging that disagrees with pooled ground truth. Fix the metric functions against sklearn across thresholds.Machine coding and LLD3 min readWith code exampleML Training Loop Gradient Bug Coding ProblemAn ML engineering interview problem in a real Python repository: a from-scratch logistic-regression trainer whose regularization gradient has the wrong sign, so loss diverges. Fix the training loop against structural, bounded tests.Machine coding and LLD3 min readWith code exampleAPI Client Pagination & Retry Coding ProblemA forward deployed engineering interview problem in a real Python repository: a paginated API client drops the last page and retries without backoff or idempotency on 429. Fix the client against an injected fake transport.Machine coding and LLD3 min readWith code exampleCustomer Data Schema Mapping Coding ProblemA forward deployed engineering interview problem in a real Python repository: inbound CSV/JSON with inconsistent types and nulls that a mapper coerces wrong and silently drops. Fix the ingestion mapping against failing tests.Machine coding and LLD3 min readWith code exampleWebhook Idempotency & Ordering Coding ProblemA forward deployed engineering interview problem in a real Python repository: out-of-order and duplicate webhook events corrupt state unless you dedupe by id and apply by version. Fix the handler against failing tests.Machine coding and LLD3 min readWith code exampleConnector Record Reconciliation Coding ProblemA forward deployed engineering interview problem in a real Python repository: a sync job whose upsert/delete diff deletes records it should keep and misses updates. Fix the reconciliation against failing tests.Machine coding and LLD3 min readWith code exampleCDC Search Index SynchronizationDebug a PostgreSQL CDC projector that misses deletes, exposes uncommitted changes, and duplicates search documents when a batch is replayed.Production debugging3 min readWith code exampleConnection Pool Exhausts After Failed RequestsFix a PostgreSQL report service that leaks pooled connections on exceptions and returns sessions while they are still idle in transaction.Production debugging3 min readWith code exampleDatabase Overload Under A Traffic SpikeRepair an order-history endpoint whose missing index, N+1 queries, and unbounded results saturate PostgreSQL during traffic spikes.Production debugging3 min readWith code exampleOne Tenant's Volume Slows Every TenantFix tenant event queries that fail partition pruning, allowing one high-volume tenant to slow reads for every customer in PostgreSQL.Production debugging3 min readWith code exampleInventory Overselling Under ConcurrencyFix a PostgreSQL reservation transaction that oversells stock and creates duplicate reservations when concurrent requests and retries collide.Production debugging3 min readWith code exampleCatalog Pagination Skips and Repeats ProductsReplace unstable LIMIT/OFFSET catalog pagination that skips, repeats, and scans deeply when products change between page requests.Production debugging3 min readWith code examplePayment Ledger ConsistencyRepair a refund workflow that permits unbalanced ledger entries, duplicate refunds, and balance drift outside a PostgreSQL transaction.Production debugging3 min readWith code exampleRead Replica Serves Stale Data After a WriteRestore session read-after-write consistency while retaining replica reads once PostgreSQL replication catches up to the write sequence.Production debugging3 min readWith code exampleOutbox Publishes Phantom and Duplicate EventsFix phantom, missing, and duplicate order events by making outbox writes atomic and concurrent PostgreSQL publishers safe.Production debugging3 min readWith code exampleZero-Downtime Column Split Loses RowsRepair an expand-contract migration whose bounded backfill skips users and whose live write path leaves new columns empty.Production debugging3 min readWith code exampleAllocation rate explosion in telemetry enrichment hot pathUse allocation evidence to optimize a telemetry enrichment path that creates short-lived garbage and drives constant GC without retaining memory.Production debugging3 min readWith code exampleCoarse lock convoy in shared registryDiagnose a feature registry whose exclusive lock serializes cheap readers behind an expensive rebuild and destroys throughput under load.Production debugging3 min readWith code exampleEvent listener registration leak in a collaboration serverUse heap evidence to find closed collaboration sessions retained by a process-wide event bus and restore listener lifecycle symmetry.Production debugging3 min readWith code exampleFinalizer and cleaner backlog in a scratch file serviceMake scratch-file cleanup deterministic when finalizers cannot keep pace, leaving file descriptors and temporary files alive after jobs finish.Production debugging3 min readWith code exampleFull Result Materialization Heap SpikeFix a CSV export that materializes an entire database result before chunking, making peak heap grow with rows instead of chunk size.Production debugging3 min readWith code exampleHumongous allocation region pressureReshape a renderer that allocates one contiguous payload-sized buffer per request, triggering expensive GC cycles at low heap occupancy.Production debugging3 min readWith code exampleLock leaked on exception pathUse a thread dump to diagnose a settlement lock that remains owned after poisoned input throws, blocking every later request forever.Production debugging3 min readWith code exampleLock ordering deadlock in transfer pathRead a deadlocked ledger thread dump and establish deterministic lock ordering for simultaneous opposite-direction account transfers.Production debugging3 min readWith code exampleMissed signal in a handoff queueDiagnose consumers parked during shutdown because queue state changes and condition-variable signaling do not form a correct protocol.Production debugging3 min readWith code exampleOff-Heap Buffer Churn Full GC StormRead GC evidence showing full collections reclaim almost no heap, then bound native buffer churn with a reusable pool.Production debugging3 min readWith code exampleRule bundle reloads never release the previous generationUse heap retainer evidence to find why hot-reloaded rule bundles, classes, and generation state never become collectible.Production debugging3 min readWith code examplePremature promotion and survivor overflow in a batch rollupReshape a batch rollup whose retained intermediates overflow survivor space and promote short-lived records into the old generation.Production debugging3 min readWith code exampleThread-local retention in pooled workersTrace request contexts retained by long-lived worker thread-local storage after a payment pipeline has completely drained.Production debugging3 min readWith code exampleThread pool starvation from nested task submissionDiagnose a fixed executor where every batch worker blocks waiting for shard tasks queued to the same fully occupied pool.Production debugging3 min readWith code exampleUnbounded Cache Heap ExhaustionUse heap evidence to repair a freight quote cache that retains request-specific keys, misses reuse, and grows with total traffic.Production debugging3 min readWith code exampleSeat Reservation SystemConcurrent seat holds, validation before mutation and listing order.Machine coding and LLD8 min readWith code exampleConcurrent Bank TransferTransfers between accounts without deadlocks or lost updates.Machine coding and LLD8 min readWith code exampleRate LimiterToken bucket and sliding window limiters, per client and under concurrency.Machine coding and LLD8 min readWith code example