Code RoomIdempotency key reused under concurrency
HardPrep Room Coding #4017

Idempotency key reused under concurrency

Vibe & agenticAlgorithms & data structuresSenior–Staff~18 min

You're using a coding agent to add idempotency to a payment-creation endpoint in a Java service. Twice it has produced code that 'works' in the happy path but reuses the idempotency key incorrectly under concurrent duplicate requests — the second request still creates a charge. Each fix tweaks the surface but misses the race. How do you diagnose why it keeps getting this wrong, and how do you re-steer or take over?

Implement
resolve_idempotent_charges(request_keys: list[str]) → list[int]
Examples
in[["a","b","a"]]out[1,2,1]
in[["k","k","k","k"]]out[1,1,1,1]
in[[" x ","x"]]out[1,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.