High-frequency matching engine monitors at Two Sigma, HRT, and Citadel track active resting order memory allocations. You are given a list of orders, where each order is defined by its lifespan interval in nanoseconds (half-open interval: active from inclusive up to exclusive).
Your Task
Implement max_active_orders(intervals: list[list[int]]) -> int that determines the maximum number of simultaneously active orders present in the matching engine at any nanosecond in time.
Constraints
Examples
intervals = [[0, 30], [5, 10], [15, 20]]
# At t=7: orders [0, 30] and [5, 10] are active (2 orders).
# At t=17: orders [0, 30] and [15, 20] are active (2 orders).
# Output: 2
intervals = [[7, 10], [2, 4]]
# No overlap. Max active = 1.
# Output: 1