Heaps

47 articles

dsa19 min read

Kth Largest Element in a Stream — Min-Heap Design [Amazon Easy]

Design a class to track the kth largest element in a live data stream. Learn why a min-heap of exactly k elements is the perfect data structure, trace through a full dry run, avoid the classic pitfalls, and walk away with clean Python and JavaScript solutions ready for FAANG interviews.

Read →
dsa8 min read

Meeting Rooms II — Minimum Conference Rooms via End-Time Heap

Find the minimum number of conference rooms required for all meetings by tracking room availability with a min-heap of end times — a classic interval scheduling problem asked at every major tech company and fundamental to resource allocation.

Read →
dsa9 min read

IPO — Greedy Capital Maximization with Two Heaps

Maximize capital after k IPO investments by unlocking affordable projects into a max-profit heap — a sophisticated two-heap greedy problem asked at Google, Amazon, and Facebook that models real-world portfolio optimization.

Read →
dsa5 min read

Super Ugly Number — Multi-Pointer Heap DP Interview

LeetCode 313 Super Ugly Number is a generalization of Ugly Number II asked in Amazon and Google interviews. Generate the nth number whose only prime factors are in a given list using min-heap or K-pointer DP.

Read →
dsa6 min read

Design Twitter — K-Way Merge News Feed Interview

LeetCode 355 Design Twitter is a Meta and Twitter system design interview classic. Build post, follow, unfollow, and getNewsFeed using a per-user tweet list and a K-way merge max-heap.

Read →