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
Coding & Algorithms
Software Engineer
Nubank
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
idempotency
hash maps
sliding time window
Pix retries
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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 ...


Submit Your Answer
Markdown supported

Related Questions