← All sections

Heap

A tree on the inside; revisits earlier problems with the new tool.

0/5 lessons · exam: 0/30%

Lessons

  1. ✓01

    Recognizing heap problems

    What a heap is, the heap property, push/pop in O(log n), and when it is the tool.

  2. ✓02

    Pattern 1: Top-K with a heap of size K

    Keeping only the K best in a fixed-size heap — the k-th largest in O(n log k).

  3. ✓03

    Pattern 2: Merging K sources (k-way merge)

    The heap always picks the next smallest among K lists — merge k revisited.

  4. ✓04

    Pattern 3: Two heaps (median of a stream)

    Splitting the data into two balanced halves to find the median in O(log n).

  5. ✓05

    Synthesis: which pattern to use?

    The Heap section's decision tree and the general quiz before the final exam.

🏁 FINAL EXAM

1 easy + 1 medium + 1 hard — unseen problems

With hidden test cases, just like the real LeetCode. This is where you confirm you can leave the section solving any problem of the topic.