Quant Memo
Coding/●●●●●

Total price range covered by quotes

Several quotes each cover a price range [low, high], and the ranges may overlap. Compute the total length of the price axis that is covered by at least one quote, overlaps counted once.

ranges = [[1, 3], [2, 5], [7, 9]]
-> 6            # covered [1,5] (length 4) and [7,9] (length 2)

Return the total covered length. 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