Priority-queue

36 articles

dsa9 min read

Merge K Sorted Lists — Min-Heap and Divide & Conquer Explained

Master two optimal approaches to merge k sorted linked lists: min-heap for O(n log k) time and divide-and-conquer for O(n log k) with lower constant factors. A top-tier interview problem at Amazon, Google, Facebook, Microsoft, and Uber that tests your mastery of heaps and recursive merging.

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 →
dsa7 min read

Task Scheduler — Greedy Cooldown Formula and Priority Queue

Find the minimum CPU intervals to execute all tasks with cooldown n using a greedy formula based on maximum frequency. A key FAANG problem testing greedy reasoning, frequency counting, and optionally heap-based simulation asked at Amazon, Google, and Facebook.

Read →