Calendar Gatekeeper: Accepting Non-Overlapping Reservations

You are building a small reservation desk for a shared recording studio. A reservation occupies the half-open time interval [start, end): it begins at start and releases the room exactly at end.

Design a class named Solution with this API:

  • Solution(): create an empty calendar.
  • book(start, end): request the interval [start, end). Return true and keep it when it does not overlap any accepted reservation. Return false when it overlaps an accepted reservation, leaving the calendar unchanged.

Two reservations that touch at one endpoint are compatible. For example, [2, 5) and [5, 8) can both be accepted. Every call uses 0 <= start < end <= 1,000,000.

Return values must be produced in call order. Rejected requests do not become reservations and therefore must not block later requests.

Examples
Input: [["Solution","book"],[[],[0,1]]]
Output: [null,true]
Hints

Calendar Gatekeeper: Accepting Non-Overlapping Reservations

You are building a small reservation desk for a shared recording studio. A reservation occupies the half-open time interval `[start, end)`: it begins at `start` and releases the room exactly at `end`.