We’re preparing your current view and syncing the latest data.
Implement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking. A double booking happens when two events have some non-empty intersection (i.e., there is some time that is common to both events). Your class will have one method, book(int start, int end) which returns true if the event can be added to the calendar successfully without causing a double booking, or false otherwise. The interval [start, end) represents a booking on the half-open interval which includes start and excludes end.
The input consists of calls to the method book with two integers start and end.
For each call to book, return a boolean indicating whether the new event can be added without double booking.
0 <= start < end <= 10^9; At most 1000 calls will be made to book.
Example 1
Input
book(10, 20); book(15, 25); book(20, 30)
Output
true false true
Explanation
The first booking is successful because the calendar is empty. The second booking (15, 25) overlaps with (10, 20), so it returns false. The third booking (20, 30) does not overlap with any existing booking, so it returns true.