Union of K Sorted Iterators

Problem

Given k iterators over sorted inputs, produce a single sorted iterator over their union, de-duplicated.

Input / Output

  • Input: k iterators, each yielding elements in sorted order.
  • Output: one iterator yielding the merged, de-duplicated union in sorted order.

Constraints

  • Iterators may be large or lazy — avoid materialising everything in memory.

Example

[1,3,5],[2,3,6] -> 1,2,3,5,6
added …
LeaderboardSalaryAccount