Incomplete requests
Your task
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.
Examples
unanswered_requests(lines: list[str]) -> list[str]Example 1
Input
unanswered_requests(["REQ a1", "REQ b2", "RESP a1", "REQ c3"])Output
["b2", "c3"]