Martingales in Quant Interviews

One definition, one theorem, and one famous trick solve a whole family of otherwise-brutal interview questions.

A martingale is a process whose expected next value, given everything you have seen, equals its current value: $E[X_{n+1} \mid \mathcal{F}_n] = X_n$. A fair game. That one line, plus the optional stopping theorem, turns several notoriously hard interview questions into three-line arguments — which is exactly why quant research and trading loops keep asking them.

The tool: optional stopping

If $X_n$ is a martingale and $\tau$ is a well-behaved stopping time (bounded, or the process is bounded), then $E[X_\tau] = E[X_0]$ — a fair game stays fair even when you choose when to quit. Interview questions are usually engineered so the conditions hold; the skill is constructing the right martingale for the problem.

Three constructions to know cold

  • The wealth martingale. Symmetric random walk $S_n$ is a martingale — instant answers to gambler's-ruin probabilities: starting at $a$, chance of reaching $N$ before 0 is $a/N$.
  • $S_n^2 - n$. Also a martingale for the symmetric walk — gives expected exit TIMES: from $a$, expected time to hit 0 or $N$ is $a(N-a)$.
  • The gambling-team / ABRACADABRA construction. Expected number of fair-coin flips to see a pattern equals the sum of payouts to a team of gamblers betting on it — for HH it is $2^2 + 2 = 6$, for HT exactly $2^2 = 4$, and for the word ABRACADABRA on a 26-letter alphabet, $26^{11} + 26^4 + 26$ (the overlaps ABRA and A pay too). Interviewers ask this precisely because brute force is hopeless.

The trap: the betting "martingale"

The doubling-down betting system shares the name and none of the math. A good interviewer may bait you with it: "double your bet after each loss — you always win 1 eventually, so is it free money?" No — the strategy needs unbounded bankroll, and with any finite capital the small probability of a catastrophic streak exactly offsets the frequent small wins (optional stopping again: a fair game cannot be made favorable by a stopping rule). Saying that crisply is worth a lot in the room.

Practice with solutions

More topic guides

Frequently asked questions

What is a martingale in simple terms?

A process modeling a fair game: given everything observed so far, the expected next value equals the current value. Symmetric random walks and (driftless) Brownian motion are the canonical examples.

What is the optional stopping theorem used for in interviews?

It says a fair game stays fair under a well-behaved quitting rule: E[X at the stopping time] = E[X at the start]. Constructing the right martingale plus optional stopping gives short solutions to gambler's-ruin probabilities, expected exit times, and pattern-waiting problems.

What is the ABRACADABRA problem?

Compute the expected number of random letters until ABRACADABRA appears. The gambling-team martingale gives 26^11 + 26^4 + 26 — each term corresponding to a suffix of the word that is also a prefix (ABRACADABRA, ABRA, A). The same trick gives 6 flips for HH vs 4 for HT.

Is the martingale betting system a real martingale?

No — it is a betting strategy (double after each loss) that shares only the name. Optional stopping is precisely the theorem that shows no stopping or staking rule can turn a fair game favorable with finite capital.

Practice the real thing

QuantVault has 2,800+ quant interview problems with full solutions, intuition, and hints, firm-by-firm interview funnels, and an auto-graded coding judge. Start free.