How it works
Min and max heaps
A min heap keeps the smallest element at the root; a max heap keeps the largest.
Operations
Insert and extract are O(log n) via sift-up and sift-down; peeking the top is O(1).
Interview uses
Top-K elements, merging sorted lists, and scheduling problems often use heaps.