← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Google/Leetcode 729. My Calendar I
CodingMust
You need to implement an event booking system that manages time slot reservations. The system should support adding new bookings while ensuring that no two bookings overlap in time.
Implement the EventBooking class with the following interface:
EventBooking(): Initializes the booking system with no existing reservationsreserve(start, end): Attempts to book a time slot for the half-open interval [start, end). Returns true if the booking succeeds (no overlap with existing bookings), or false if it conflicts with an existing reservationA half-open interval [start, end) includes all times t where start <= t < end. Two intervals overlap if they share any common time point.
reserve method must return true only if the new booking does not overlap with any existing booking0 <= start < end <= 10^91000 calls will be made to reserveExample 1:
` Input: reserve(10, 20) reserve(15, 25) reserve(20, 30) Output: true false true Explanation:
Example 2:
` Input: reserve(5, 10) reserve(10, 15) reserve(0, 5) reserve(7, 12) Output: true true true false Explanation: