All Posts

1582 articles

dsa6 min read

Design Phone Directory — Available Number Pool Management

Design a phone directory that manages available and allocated numbers with O(1) get, check, and release. Uses a queue of free numbers and a boolean availability array—the same pattern used in IP address allocation and database connection pools.

Read →
dsa6 min read

Design In-Memory Database — Multi-Field Filtering

Design an in-memory key-value database with field-level get, set, delete, and sorted scan operations. Uses nested hashmaps and sorted structures—the foundation of Redis hashes and LeetCode contest scoring.

Read →
dsa5 min read

Design Min Stack — O(1) Minimum with Auxiliary Stack

Implement a stack that retrieves the minimum element in O(1) using a parallel auxiliary stack. A foundational design pattern asked at Amazon, Google, and Meta—and used in undo systems and expression evaluators.

Read →
dsa6 min read

Find Median from Data Stream — Two-Heap Approach

Maintain a running median from a data stream using two heaps: a max-heap for the lower half and a min-heap for the upper half. A classic FAANG hard problem used in analytics engines and streaming data pipelines.

Read →
dsa6 min read

Design Circular Queue — Ring Buffer Implementation

Implement a circular queue (ring buffer) with O(1) enqueue, dequeue, and peek using head/tail pointer arithmetic. Used in embedded systems, producer-consumer pipelines, and network packet buffers at Amazon and Qualcomm.

Read →
Page 157 of 317