Classify Retried Pix Requests by Idempotency Key and Window
Last updated: November 29, 2026
Quick Overview
Given Pix transfer requests in arrival order, each with a request id, an idempotency key, a timestamp and a payload (destination key and amount), label each one accepted, duplicate (same key and same payload within W seconds of the accepted request) or conflict (same key, different payload, within W).
Nubank
November 29, 20260
0
0 solved
Given Pix transfer requests in arrival order, each with a request id, an idempotency key, a timestamp and a payload (destination key and amount), label each one accepted, duplicate (same key and same payload within W seconds of the accepted request) or conflict (same key, different payload, within W).
Mobile clients on flaky networks retry Pix submissions, and a double-sent transfer is real money leaving a customer's NuConta, so idempotency is a natural warm-up in a Nubank backend screen. The interviewer checks a clean single-pass hash map solution and whether you notice that a reused key with a different payload is a bug, not a retry.
What the Interviewer Expects
- Uses a dictionary keyed by idempotency key storing the accepted timestamp and payload
- Distinguishes a harmless duplicate from a conflicting reuse of the key
- Defines the window boundary precisely (strictly less than W)
- Runs in O(n) time with O(distinct keys) memory
- Mentions that duplicates should return the original transfer result rather than an error
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you evict old keys so memory stays bounded on a service handling millions of transfers per hour?
- Requests can arrive slightly out of order across pods. What changes?
- Where should this state live so that two app instances agree (database unique constraint, Redis, Datomic)?
- Should the window restart when a duplicate arrives?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list of (req_id, key, ts, payload) with non-decreasing ts, and a window W. A request is a duplicate if its key was accepted less than W seconds ago with the same payload, a **confli...
High-Level Design
One pass with a map key -> (accepted_ts, payload). For each request look up the key: if present and inside the window, compare payloads; otherwise accept and overwrite. In production the same logic ...