Build a method bookApi(int id, int startTime, int endTime) that returns a boolean if we can book a room with id at the current timeslot (similar to Meeting Rooms II). Asked in the interview 1 stage.
Implement the Python function bookApi(bookings, id, startTime, endTime). bookings is a dictionary whose string room IDs map to sorted, non-overlapping interval lists. Each interval is [start, end], using half-open ranges [start, end). If the requested interval does not overlap an existing interval for that room, insert it and return True; otherwise return False without changing the schedule.
def bookApi(bookings, id, startTime, endTime):