My Calendar III
HardIntervals
Decode it first. Clues, constraints, pattern and plan before any code.Build a MyCalendarThree class. Every call to book(start, end) adds the half-open event [start, end); bookings are never rejected. After each booking, return the largest k such that some moment is covered by k events, counting every event booked so far.
cal = MyCalendarThree()
cal.book(10, 20) → 1
cal.book(50, 60) → 1
cal.book(10, 40) → 2
cal.book(5, 15) → 3 (10 to 15 is covered three times)
cal.book(5, 10) → 3
cal.book(25, 55) → 3The TypeScript class has the same shape: new MyCalendarThree() and cal.book(start, end).
Constraints
0 <= start < end <= 10^9- At most
400calls tobook.