Code RoomConcurrent map mutation race
MediumPrep Room Coding #4147

Concurrent map mutation race

Vibe & agenticConcurrencyMid–Senior~18 min

An AI wrote this Go in-memory metrics aggregator that's updated from many request-handling goroutines. It says maps are fine for this. Review concurrency safety.

What fails at runtime, and what's the proper fix?

Implement
replay_metrics(event_lines: list[str]) → list[str]
Examples
in[["incr|a","incr|b","incr|a","snap|s1"]]out["s1:a=2","s1:b=1"]
in[["incr|a","snap|s1","incr|a","incr|c","snap|s2"]]out["s1:a=1","s2:a=2","s2:c=1"]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 18 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.