Your question is Data Structures for Performance. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Inspire11's Delivery Intelligence workspace receives deployment and delivery windows that can be added, cancelled, and queried while a scheduling session is active. Implement an efficient structure that returns the maximum number of overlapping active windows whenever a query is issued.
Each delivery window covers the half-open interval [start, end), so a window ending at time t does not overlap one starting at t.
Write process_windows(operations). operations is a list where each operation is one of:
['add', window_id, start, end], adding a window.['remove', window_id], removing an existing window.['query'], recording the current maximum overlap.Return a list of integers containing one result for each query, in operation order. Window identifiers are unique while active. All removals are valid.
def process_windows(operations):