Back to Dashboard

Pro pattern

Upgrade to Pro to access this pattern and all 22 patterns.

Upgrade
PATTERN

Heaps / Priority Queues

Use heaps (priority queues) to efficiently find and maintain the smallest or largest elements. Master the size-k heap pattern for top-k problems, the two-heap pattern for medians, and heap-based k-way merge for combining sorted sequences.

Learn Heaps / Priority QueuesExplanation, templates & reference

Kth Largest Element in a Stream

easy

K Closest Points to Origin

medium

Kth Largest Element in an Array

medium

Task Scheduler

medium

Merge K Sorted Lists

medium

Find Median from Data Stream

hard