Back to problems

Implement a Priority Queue from Scratch

Low-Level Design · Amazon · Medium

Approach — Binary Min-Heap The problem asks us to build a priority queue from scratch, specifically a min-priority queue that can return (and remove) the smallest element efficiently. A binary heap backed by an array is the standard way to achieve this. The key property of a min-heap is that each parent node is no larger than its children, which guarantees the minimum sits at the root (index 0 in the array). We need to support push (insert) and pop (remove the minimum), both…

Checking your access…