Your question is Max Overlapping Events. 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.
Cohere monitors intervals during which requests to products such as the Cohere API are being processed. Given request intervals and a time window, return the maximum number of requests active simultaneously within that window.
Treat every interval as half-open: [start, end). An event is active at time t when start <= t < end. Events ending at time t do not overlap events starting at time t.
Implement max_overlapping_events(events, window_start, window_end), where events is a list of two-element lists [start, end], and all timestamps are integers. The function must consider only the portions of events that intersect [window_start, window_end). Return an integer representing the greatest number of simultaneously active events in that window. Return 0 if no event intersects the window.
def max_overlapping_events(events, window_start, window_end):