Concurrent transfer balance mismatch
An AI assistant wrote this Java method to transfer funds between two accounts. Code review passed, tests pass. Under concurrent load, a few accounts end up with balances that don't reconcile.
What concurrency hazard exists despite `@Transactional`, and how do you fix it?
Implement
apply_transfers(balances: list[int], transfers: list[str]) → list[int]Examples
in
[[1000,500],["0,1,300"]]out[700,800]in
[[100,100],["0,1,150"]]out[100,100]in
[[100,0],["0,1,100","0,1,1"]]out[0,100]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 20 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.
Run or narrate your approach, then ask the coach.