Code RoomSeat hold expiry
EasyPrep Room Coding #4809

Seat hold expiry

CodingAlgorithms & data structuresEntry–Mid~18 min

A box office parks a seat for a buyer while checkout runs. events replays what happened, one entry per line written "second|action|seat|customer", given in nondecreasing order of second. action is either hold or confirm, and seat and customer names carry no bar and no equals sign. A hold placed at second t belongs to that customer from t through t plus hold_seconds minus 1 and is gone at t plus hold_seconds. A hold is granted only when the seat is unsold and carries no live hold, so a buyer asking again for a seat they already hold is refused and the original expiry stands. A confirm works only when that same customer's hold is still live at that second, and it sells the seat for good, so every later event touching that seat does nothing. Return one "seat=customer" entry per sold seat, sorted by seat name as ordinary text.

Implement
settle_seat_holds(events: list[str], hold_seconds: int) → list[str]
Examples
in[["10|hold|A1|nina","10|hold|A2|omar","12|confirm|A1|nina","40|confirm|A2|omar"],30]out["A1=nina"]
in[["0|hold|B3|pia","0|hold|B3|quinn","5|confirm|B3|quinn","9|confirm|B3|pia"],10]out["B3=pia"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 18 min
InputExpectedGot
[["10|hold|A1|nina","10|hold|A2|omar","12|confirm|A1|nina","40|confirm|A2|omar"],30]["A1=nina"]not run yetsample
[["0|hold|B3|pia","0|hold|B3|quinn","5|confirm|B3|quinn","9|confirm|B3|pia"],10]["B3=pia"]not run yetsample