Quant Memo
Coding/●●●●

Merge k sorted price feeds

Asked at Optiver, Jump Trading

You have k sorted lists (each ascending) and want a single sorted list of everything.

[[1, 4, 5], [1, 3, 4], [2, 6]]
-> [1, 1, 2, 3, 4, 4, 5, 6]

Merge them in O(Nlogk)O(N \log k) where N is the total number of elements. Concatenating and re-sorting is O(NlogN)O(N \log N).

Your answer

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

More Coding questions