729. My Calendar I

Practice My Calendar I for free on NudgeCode: Medium, Binary Search pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Design a calendar that accepts an event only if it does not double book, i.e. overlap an event already in the calendar. An event is the half-open interval [startTime, endTime), so [10, 20) and [20, 30) do not overlap.

Each test is a list of operations and their arguments; the expected output lists what each call returns (null for the constructor).

Example

["MyCalendar","book","book","book"]
[[],[10,20],[15,25],[20,30]]
->  [null,true,false,true]

Constraints