Quant Memo
Coding/●●●●●

Merge overlapping trading sessions

Asked at Two Sigma, IMC

A venue publishes trading sessions as [open, close] time intervals, but some overlap or touch. Merge them into the fewest disjoint intervals that cover the same time.

sessions = [[9, 11], [10, 12], [13, 14]]
-> [[9, 12], [13, 14]]     # the first two overlap and fuse

Return the merged, non-overlapping sessions sorted by start. Aim for 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