Code Room
CodingMediumcod-g653
Subject Sweep lineLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Implement a calendar that processes a sequence of bookings, each a half-open interval [start, end). After each booking, you must report the maximum number of bookings that overlap at any single point in time across ALL bookings so far (the 'k-booking' level). Given the list of bookings in order, return a list whose i-th element is that running maximum after the i-th booking is added. Use a sweep over interval endpoints (a count delta of +1 at start, -1 at end).

Implement
calendar_three(bookings: list[list[int]]) → list[int]
Examples
in[[[10,20],[50,60],[10,40],[5,15],[5,10],[25,55]]]out[1,1,2,3,3,3]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.