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

Question

A mobile client retries flaky uploads, so the ingestion log can contain several lines for the same request id, each of the form "<request_id> <status>". Later lines for an id supersede earlier ones. Collapse the log so each request id appears exactly once, formatted as "<request_id> <status>" with its most recent status — but keep the ids in the order in which they FIRST appeared. Return the collapsed lines.

Implement
dedupe_retries(lines: list[str]) → list[str]
Examples
in[["r1 pending","r2 pending","r1 failed","r1 succeeded"]]out["r1 succeeded","r2 pending"]
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.