Collision Odds for Short Refund Reference Codes

Last updated: November 29, 2026

Quick Overview

A team proposes giving each daily refund a random 6-character alphanumeric reference code shown to users. With about one million refunds a day, estimate the chance of at least one collision and the code length needed to keep it under one in a million per day.

PhonePe
Statistics & Math
Data Scientist
PhonePe
November 29, 2026
Data Scientist
Phone Screen
Statistics & Math
Easy

0

0

0 solved


A team proposes giving each daily refund a random 6-character alphanumeric reference code shown to users. With about one million refunds a day, estimate the chance of at least one collision and the code length needed to keep it under one in a million per day.

PhonePe generates huge volumes of human-readable references for refunds, disputes and support tickets, and short random IDs feel safe but collide far sooner than intuition suggests. The interviewer checks the birthday-problem approximation and whether you translate it into a concrete engineering recommendation.

What the Interviewer Expects
  • Recognize the birthday problem and set up the pair count
  • Use the Poisson approximation $P \approx 1 - e^{-n^2/2N}$
  • Compute numbers to the right order of magnitude
  • Solve for the code length that meets the target
  • Recommend a practical design, not just a number
Key Topics to Cover
birthday problem
Poisson approximation
probability
ID design
logarithms
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
  • How does the answer change if codes must be unique across a whole year?
  • Would you drop easily confused characters like 0/O and 1/I, and what does it cost?
  • Why not just use a database sequence number?
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

Alphabet: 26 letters plus 10 digits = 36 symbols, uniformly random. Codes are unique per day (the day can be part of the lookup key). n is about 10610^6 refunds per day. We want $P(\text{any collision ...

Approach

With NN possible codes and nn draws, the expected number of colliding pairs is λ=(n2)/N≈n2/(2N)\lambda = \binom{n}{2}/N \approx n^2/(2N). For small per-pair probability, the number of collisions is close to Poiss...


Submit Your Answer
Markdown supported

Related Questions