Code Room
CodingMediumcod-g1315
Subject Log processingLevel Entry–Mid~13 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.