In-Memory Meeting Room Manager
Learn this problemProblem statement
Build an in-memory meeting-room manager that processes an ordered list of command strings. Initially, there are no active reservations.
Each command uses single spaces between tokens and has one of these forms:
RESERVE id room start endrequests reservationidforroomduring the half-open interval[start, end). The operation succeeds only whenidis not already active and the interval does not overlap any active reservation for the same room. Reservations in different rooms do not conflict. Intervals that only touch, such as[10, 20)and[20, 30), do not overlap.DELETE idremoves the active reservation with that ID. It succeeds when the ID is active and fails otherwise. A successfully deleted ID may be used again later.
Return one boolean for every command in input order. A successful operation contributes true; a rejected operation contributes false. A rejected operation never changes the manager state.
Function
processMeetingRoomOperations(operations: List<String>) → boolean[]Examples
Example 1
operations = ["RESERVE m1 atlas 10 20","RESERVE m2 atlas 20 30","RESERVE m3 atlas 15 25","RESERVE m3 zephyr 15 25","DELETE m1","RESERVE m4 atlas 12 18","DELETE missing"]return = [true,true,false,true,true,true,false]The first two Atlas reservations touch at time 20, so both succeed. The overlapping Atlas request for m3 fails and leaves that ID available; the same ID can then reserve the independent Zephyr room. Deleting m1 opens its former interval for m4.
Example 2
operations = ["RESERVE r1 north 5 10","RESERVE r1 south 10 15","DELETE r1","DELETE r1","RESERVE r1 south 10 15","RESERVE r2 south 9 10","RESERVE r3 south 14 16"]return = [true,false,true,false,true,true,false]An active reservation ID is globally unique, even across rooms. After r1 is deleted, the second deletion fails and the ID can be reused. Reservation r2 touches r1 at time 10, while r3 overlaps it.
Constraints
1 <= operations.length <= 100000- Each operation has exactly one documented form.
- Each reservation ID and room name has between
1and32lowercase ASCII letters, digits, or hyphens. - Every
startandendis a decimal integer string satisfying0 <= start < end <= 10^9. - The total number of characters across all operations is at most
2000000.