A `k`-booking happens when `k` events have some non-empty intersection (i.e., there is some time that is common to all `k` events.) You are given some events `[startTime, endTime)`, after each given event, return an integer `k` representing the maximum `k`-booking between all the previous events. Implement the `MyCalendarThree` class: - `MyCalendarThree()` Initializes the object. - `int book(int startTime, int endTime)` Returns an integer `k` representing the largest integer such that there exists a `k`-booking in the calendar.
Example 1
Input: operations = ["MyCalendarThree","book","book","book","book","book","book"], args = [[],[10,20],[50,60],[10,40],[5,15],[5,10],[25,55]]
Output: [null,1,1,2,3,3,3]
Explanation: The first two events do not overlap (max 1). [10,40) overlaps [10,20), raising the max to 2. [5,15) overlaps both during 10-15, raising it to 3. The last two events never push any moment above 3 bookings.
Example 2
Input: operations = ["MyCalendarThree","book","book"], args = [[],[1,2],[2,3]]
Output: [null,1,1]
Explanation: The half-open intervals [1,2) and [2,3) only touch at 2, so no moment is booked twice and the answer stays 1.
Example 3
Input: operations = ["MyCalendarThree","book","book","book"], args = [[],[0,10],[0,10],[0,10]]
Output: [null,1,2,3]
Explanation: Each new copy of [0,10) stacks on the same time range, so the maximum booking grows 1, 2, 3.
Represent each event as +1 at its start and -1 at its end on a timeline. The maximum number of simultaneously-active events is the maximum running prefix sum over the sorted timeline. After each booking, recompute that maximum.
Run checks all cases above. Submit evaluates all test cases.