Opening your learning path
Progress is saved as you study.
Opening your learning path
Progress is saved as you study.
The Heap (Priority Queue) Patterns pattern applies when you need top K elements, K-way merge, two heaps for median, and scheduling. Its time complexity is O(n log k) and space complexity O(k). It is used in 26 problems on Thita, including Design Twitter, Finding MK Average and Find K Pairs with Smallest Sums. Common variations are Two Heaps for Median Finding and Top K Elements (Selection/Frequency).
Master heap-based algorithms including top K elements, two heaps for median, K-way merge, and scheduling problems with priority queues.
Heap (Priority Queue) Patterns is pattern 9 of 16 in the Thita.ai DSA course. It covers top K elements, K-way merge, two heaps for median, and scheduling, split into 4 subpatterns and about 2 hours of study. It is one of the interview-critical patterns, so it is worth covering before your first onsite.
Each subpattern below has its own theory page and problem set. They are listed in the order the course teaches them.
Read the theory for a subpattern, then solve its problems in the browser editor. Your solution runs against the problem's test cases, and the AI coach gives a hint on the technique you are missing rather than the finished answer. Progress is tracked per subpattern, so the tracker shows which of the 4 Heap (Priority Queue) Patterns subpatterns you have covered. Topics covered here include heap, priority queue, top k elements, kth largest, k-way merge, two heaps median, min heap, max heap.
26 problems, easiest first.
Fetching theory for Top K Elements (Selection/Frequency)...