How Long Must Transaction Reference IDs Be to Avoid Collisions

Last updated: November 29, 2026

Quick Overview

PayPal generates random transaction reference IDs from a 32-character alphabet. With 40 million new transactions per day, estimate the expected number of collisions per day for 8-character IDs, and find the shortest length that keeps the probability of any collision in a year below one in a million.

PayPal
Statistics & Math
Software Engineer
PayPal
November 29, 2026
Software Engineer
Onsite
Statistics & Math
Medium

0

0

0 solved


PayPal generates random transaction reference IDs from a 32-character alphabet. With 40 million new transactions per day, estimate the expected number of collisions per day for 8-character IDs, and find the shortest length that keeps the probability of any collision in a year below one in a million.

Short, human-readable reference IDs appear on PayPal receipts and in support conversations, and collisions cause misrouted lookups. This birthday-problem question checks the $n^2/2N$ approximation, unit handling with large exponents, and the engineering conclusion that uniqueness should still be enforced.

What the Interviewer Expects
  • Apply the birthday approximation for expected collisions
  • Compute ID space size correctly as 32^L = 2^(5L)
  • Scale from a day to a year correctly (n grows, collisions grow as n squared)
  • Solve for the minimum length
  • Recommend uniqueness constraints and retry, not just longer IDs
Key Topics to Cover
birthday problem
combinatorics
approximation
ID generation
How to Approach This
  1. Define your hypotheses (H0 and H1) clearly before performing any test.
  2. Calculate required sample size BEFORE running an experiment, using power analysis.
  3. Remember the Central Limit Theorem: sample means become approximately normal with large n.
  4. Watch for Simpson's paradox. Always segment data by key dimensions.
  5. Distinguish between statistical significance and practical significance.
Possible Follow-up Questions
  • Does it matter whether collisions must be unique per day or forever?
  • How would a timestamp prefix change the math?
  • Why might you avoid characters like 0, O, 1 and I, and how does that change N?
  • What other risk do short random IDs create (guessability)?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Browse Statistics Questions
Sample Answer
Clarify

IDs are uniformly random strings of length LL over 32 symbols, so the space is N=32L=25LN = 32^L = 2^{5L}. Collisions are counted among all IDs that must be unique together; first per day, then over a year ...

Approach

Expected number of colliding pairs among nn random draws from NN values is (n2)/N≈n22N\binom{n}{2}/N \approx \frac{n^2}{2N}. When this is small, $P(\text{any collision}) \approx 1 - e^{-n^2/2N} \approx \frac...


Submit Your Answer
Markdown supported

Related Questions