Heap Interview Problems

Common heap applications : merge k lists, max overlap, halve array sum

#resource / algorithm #type / concept #status / growing #ds / heap

[!info] related notes 算法面试题型 MOC

Heap Interview Problems

Merge k Sorted Lists

  • Use a min-heap keyed by node value.
  • Initialize heap with each list head.
  • Pop smallest, append to result, then push its next.
  • Reference: 合并K个有序链表

Maximum Overlapping Segments

  • Sort segments by start.
  • Use a min-heap of end points.
  • For each segment:
    • Pop ends <= start.
    • Push current end.
    • Heap size is overlap count at this point; track max.
  • Reference: 线段最多重合问题

Min Operations to Halve Array Sum

  • Use a max-heap.
  • Repeatedly take current max, halve it, put back, accumulate reduction until reached half of total sum.
  • Reference: 数组和减半最少操作
创建于 2026/3/16 更新于 2026/5/27