Code RoomIncomplete requests
MediumPrep Room Coding #501

Incomplete requests

CodingAlgorithms & data structuresEntry–Mid~13 min

An API gateway writes "REQ <id>" when a request enters and "RESP <id>" when its response leaves. Each id has at most one REQ line and at most one RESP line, and a RESP for an id always appears after its REQ. During an incident you need the requests that never completed. Given the log lines in order, return the ids that have a REQ line but no RESP line, in the order their REQ lines appear.

Implement
unanswered_requests(lines: list[str]) → list[str]
Examples
in[["REQ a1","REQ b2","RESP a1","REQ c3"]]out["b2","c3"]
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 13 min
InputExpectedGot
[["REQ a1","REQ b2","RESP a1","REQ c3"]]["b2","c3"]not run yetsample