Quant Memo
Coding/●●●●

Smallest range covering all k lists

Asked at Two Sigma, Jane Street

You have k sorted lists of numbers. Find the smallest range [a, b] (smallest b - a, ties broken by smaller a) that contains at least one number from each of the k lists.

[4, 10, 15, 24, 26]
[0, 9, 12, 20]         ->  [20, 24]
[5, 18, 22, 30]

Target O(Nlogk)O(N \log k) time for NN total elements, O(k)O(k) memory.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions