Problem
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.
Example 1
cal = MyCalendarThree()
Example 2
- Input
- cal.book(10, 20)
- Output
- 1
Example 3
- Input
- cal.book(50, 60)
- Output
- 1
Example 4
- Input
- cal.book(10, 40)
- Output
- 2
Example 5
- Input
- cal.book(5, 15)
- Output
- 3
- Why
- 10 to 15 is covered three times
Example 6
- Input
- cal.book(5, 10)
- Output
- 3
Example 7
- Input
- cal.book(25, 55)
- Output
- 3
The TypeScript class has the same shape: new MyCalendarThree() and cal.book(start, end).
Constraints
0 <= start < end <= 10^9At most 400 calls to book.