288. My Calendar I
MediumDesign
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking. A double booking happens when two events have some non-empty intersection (i.e., some moment is common to both events). Implement the MyCalendar class: - MyCalendar() Initializes the calendar object. - boolean book(int start, int end) Returns true if the event can be added without a double booking. Otherwise, return false and do not add the event.
Examples
Input: ["MyCalendar","book","book","book"] [[],[10,20],[15,25],[20,30]]
Output: [null,true,false,true]
Explanation: The second booking [15,25] overlaps [10,20].
Constraints
- 0 <= start < end <= 10^9
- At most 1000 calls will be made to book.
Loading...
Run checks all cases above. Submit evaluates all test cases.