"My Calendar I" is a LeetCode problem (729) commonly asked in Microsoft interviews, tagged with Array, Binary Search, Design, and Ordered Set.
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 a common time slot. Events are represented by start and end times as integers, using a half-open interval [startTime, endTime), meaning the event includes startTime but excludes endTime.[1][2][9]
Implement the MyCalendar class:
MyCalendar myCalendar = new MyCalendar(); myCalendar.book(10, 20); // return True myCalendar.book(15, 25); // return False (overlaps with [10,20)) myCalendar.book(20, 30); // return True (no overlap; [20,30) starts exactly at 20)
Output: [null, true, false, true][5][1][2]