Skip to main content

DSA pattern

Heap / Priority Queue

Heaps maintain partial ordering where root is always min (min-heap) or max (max-heap). Perfect for problems requiring quick access to extreme values, streaming data, or merging sorted sequences.

When to use

5 signals
  1. 01Finding top K elements
  2. 02Streaming median
  3. 03Merge K sorted lists
  4. 04Task scheduling
  5. 05Dijkstra's shortest path

In interviews, call out the pattern early. It helps interviewers follow your reasoning and keeps your implementation focused. After solving, explain tradeoffs in plain language: why this approach is efficient, where it can break, and what edge cases you would test first.

Practice problems

4 listed
  1. 01Kth Largest ElementPractice →
  2. 02Merge K Sorted ListsPractice →
  3. 03Find Median from Data StreamPractice →
  4. 04Top K FrequentPractice →

Build a review loop

Treat each pattern as a repeating cycle, not a one-time read. Solve a fresh problem today, revisit the same pattern in 2-3 days, and run one timed attempt at the end of the week. This turns short-term familiarity into reliable recall for live interviews.

When reviewing, re-derive the core steps from scratch before checking a reference solution. If you can explain the state transitions and edge cases clearly, you are much more likely to execute well under interview pressure.