Interview questions with answer breakdowns — Page 49 of 52
Browse page 49 of Offer.cc interview question and answer breakdowns with reasoning, implementation details, follow-ups, and public sources.
How Do You Design a Stable Cursor Pagination API?
Start with pagination semantics under concurrent writes, compare offset and cursor pagination, then derive a compound cursor, matching index, bidirectional queries, snapshot boundary, and adversarial tests.
Data Engineering Interview: Design an SCD Type 2 Dimension
Design a point-in-time-correct SCD Type 2 dimension with surrogate keys, half-open validity intervals, idempotent loads, delete semantics, late corrections, and invariant checks.
Coding Interview: Implement a Bounded SPSC Lock-Free Ring Buffer
Implement a fixed-capacity single-producer single-consumer ring buffer and explain indexes, full/empty checks, memory ordering, and edge tests.
System Design Interview: Design a Real-Time Collaborative Editor
Build a collaborative editor around CRDT convergence, document rooms, a durable update log, and state-vector sync while handling instant local edits, offline reconnects, ephemeral cursors, permission revocation, and testable recovery.
How Do You Diagnose and Optimize a Slow PostgreSQL Query?
Derive a multicolumn or partial index from workload evidence, execution plans, and cardinality estimates, then validate read gains against write amplification and rollout risk.
Data Engineering Interview: Design a Change Data Capture Pipeline
Derive a gap-free CDC pipeline from PostgreSQL WAL, initial snapshots, and source positions, then handle at-least-once delivery, deletes, schema evolution, replication-slot risk, replay, and reconciliation.
How Do You Implement a Fenwick Tree for Dynamic Prefix Sums and Weighted Selection?
Implement point updates, prefix and range sums, and rank-by-weight selection with a compact one-array structure while handling indexing, complexity, and negative-weight limits.
System Design Interview: Design a Centralized Logging System
Design a centralized logging platform around local buffering, a durable stream, selective indexing, and object-storage archives so it survives log storms, downstream outages, high-cardinality fields, and noisy tenants.
How Do You Prevent a Cache Stampede When a Hot Key Expires?
Design a cache read path with soft expiration, request coalescing, and distributed leases that survives hot-key expiry, refresher crashes, cache failure, and delayed writes.
Data Engineering Interview: How Do You Diagnose and Fix a Hot Kafka Partition?
Diagnose a Kafka hot partition from per-partition lag and key skew, calculate backlog growth, then choose throttling, safe intra-partition concurrency, a better key, and an ordering-safe migration.
How do you implement a skip list and explain its expected O(log N) behavior?
Build a searchable, mutable ordered structure with random levels, then reason about expected complexity, edge cases, and memory trade-offs.
System Design Interview: Design a Cloud File Storage and Sync Service
Design a cloud drive with resumable chunk uploads, immutable file versions, cursor-based device sync, conflict copies, version recovery, and safe garbage collection.
Prevent Write Skew with Transaction Isolation
Use an on-call roster invariant to derive the actual behavior of Read Committed, Repeatable Read, and Serializable, then compare serializable retries, explicit locking, and a single-row conditional update.
How Do You Diagnose Sample Ratio Mismatch in an A/B Test?
Use a chi-square test to confirm Sample Ratio Mismatch, then trace assignment, execution, log processing, and analysis filters before trusting an apparently significant experiment lift.
How do you implement Vose's alias method for O(1) weighted sampling?
Precompute probability and alias tables for constant-time sampling from a static discrete distribution, including updates, precision, and validation.
System Design Interview: Design a Distributed Lock Service
Design a distributed lock service around strongly consistent state, lease renewal, and fencing tokens so it remains safe through process pauses, partitions, lost responses, and leader failure.
Design an Idempotent Create-Order API
Start with idempotency-key scope, request fingerprints, and a database uniqueness constraint to make order creation safe to retry, including concurrent requests, lost responses, key expiry, and downstream side effects.
SQL Interview: Find the Top Three Products per Category
Aggregate order items to product grain, use DENSE_RANK to preserve revenue ties, and explain window-function order, edge cases, correctness, and validation.
How do you implement a Count-Min Sketch for streaming frequency estimates?
Use a two-dimensional counter array and independent hashes to estimate key frequencies in fixed memory, including error bounds, merges, and reset limits.
System Design Interview: Design a Large-Scale Web Crawler
Derive a host-sharded URL frontier from the crawl budget, then handle robots.txt, politeness, deduplication, recrawling, and lease recovery with testable capacity and failure invariants.
How Do You Monitor an ML Model in Production?
Use a ride-hailing ETA regressor to build layered monitoring for serving health, data quality, distribution shifts, and delayed-label quality, then map each signal to an actionable alert, rollback, or retraining decision.
How can HyperLogLog estimate distinct values in a massive stream?
Estimate streaming cardinality with fixed memory by deriving HyperLogLog register updates, error corrections, and distributed merge boundaries.
How Would You Design a Feature Flag System?
Design a low-latency feature flag platform by separating its management control plane from in-process evaluation, then make rollout assignment, stale-data behavior, governance, and failure recovery explicit.
How Do You Evaluate a Recommendation System Offline and Online?
Build a launch decision from point-in-time logged data, ranking and beyond-accuracy metrics, exposure bias, and a randomized online experiment, then diagnose why an offline win can lose online.