QuantQuestions Dice

Coin Flip Probability: Practice Problems for Quant Interviews

Coin flip problems appear in nearly every quant interview at Jane Street, SIG, and Optiver. They test your ability to set up state equations, reason about sequences, and apply classical probability results under time pressure.

Key Concepts

A fair coin has P(H) = P(T) = ½. For a sequence of n independent flips:

P(exactly k heads in n flips)C(n,k) · (½)ⁿ
P(HH in 2 flips)¼
P(at least one H in n flips)1 − (½)ⁿ
E[number of heads in n flips]n/2

These basics are warm-up only. Interviewers care about the harder structural questions: expected times until patterns, ruin probabilities, and sequence races. Those follow below.

The HH Problem: Expected Flips Until Two Consecutive Heads

Question: What is the expected number of fair coin flips until you see HH for the first time?

This is the most common coin-flip question in quant interviews. The correct answer is 6. Here is the full derivation using state equations.

State-Equation Derivation

Define three states based on what has happened at the end of the most recent flip:

  • State S₀ — start (or last flip was T): no useful progress.
  • State S₁ — last flip was H: one step toward HH.
  • State S₂ — just saw HH: done.

Let E₀ and E₁ be the expected number of additional flips to reach S₂ from S₀ and S₁ respectively.

From S₀: flip once. With probability ½ you get H (move to S₁); with probability ½ you get T (stay at S₀).

E₀ = 1 + ½·E₁ + ½·E₀

From S₁: flip once. With probability ½ you get H (reach S₂, done); with probability ½ you get T (fall back to S₀).

E₁ = 1 + ½·0 + ½·E₀

Solving:

From the second equation: E₁ = 1 + ½·E₀

Substitute into the first: E₀ = 1 + ½·(1 + ½·E₀) + ½·E₀

E₀ = 1 + ½ + ¼·E₀ + ½·E₀ = 3/2 + ¾·E₀

¼·E₀ = 3/2 → E₀ = 6

And E₁ = 1 + ½·6 = 4.

Follow-up: Expected flips until HT? The answer is 4, because once you see H you need just one more flip; falling back to T is less costly than falling back from near-HH. Interviewers ask both to check whether you truly understand state structure or just memorized E[HH] = 6.

Gambler's Ruin

Setup: You start with $k. On each flip of a fair coin you win $1 (heads) or lose $1 (tails). The game ends when you reach $N (win) or $0 (bust). What is your probability of winning?

Result (fair coin)

P(reach N before 0 | start at k) = k / N

The probability is linear in starting wealth — a clean, memorable result.

Derivation sketch: Let pₖ = P(win | start at k). The boundary conditions are p₀ = 0 and pₙ = 1. The recurrence for a fair coin is pₖ = ½pₖ₋₁ + ½pₖ₊₁, which has the general solution pₖ = A + Bk. Applying boundary conditions gives pₖ = k/N.

Biased coin extension: If P(H) = p ≠ ½, the formula becomes pₖ = (1 − (q/p)ᵏ) / (1 − (q/p)ᴺ) where q = 1 − p. When p < ½, even a large starting stack is eventually busted with probability approaching 1 as N → ∞ — the casino's edge is insurmountable over infinite time.

Why it matters for interviews: Gamblers ruin is the prototype for barrier-hitting problems in stochastic processes — a direct precursor to the reflection principle and barrier options.

Sequence Races: Which Pattern Appears First?

Question: Which sequence appears first in an infinite sequence of fair coin flips — HHT or HTT?

At first glance these look symmetric (both have probability (½)³ = 1/8 for any given three-flip window), so many candidates guess 50/50. The correct answer is HTT appears first with probability 3/4.

The Trick: Overlapping Structure

The key insight is that HHT and HTT have different self-overlapping structures, which creates an asymmetry in how easily each pattern can be "disrupted" after a partial match.

Consider: if you are one flip away from completing HHT (you have seen HH), and you flip T — you get HHT and win. But if instead you are one away from HTT (you have seen HT), and you flip T — you get HTT and win. So far symmetric.

The asymmetry shows up earlier: to start building toward HHT, you need H first. If you see H and then T, you have HT — which is the start of HTT's prefix. So any time HHT makes progress and then fails, it hands HTT a head start. HTT is a "trap" for HHT.

A clean way to see this: the only way HHT can win is if the very first flip is H and the run goes HH... before any T. That has probability approaching ½ × ½ = ¼, while HTT wins in all other scenarios — probability 3/4.

General approach: For any two competing patterns, Conway's leading number method gives the win probability in closed form without enumeration. You probably won't derive it from scratch under pressure, but knowing the result and the overlapping-structure intuition is what interviewers want to see.

Related question: Expected number of flips until HHT? It is 10. Until HTT? Also 10. Same expectation, very different race probabilities — a counterintuitive result worth remembering.

How to Approach These in Interviews

1
Name your states immediately
For any pattern or sequence problem, define your states before writing any equations. Interviewers penalize candidates who jump to algebra without a clear state diagram.
2
Write the recurrence, then solve
State equations are linear systems. Write them all out, then solve — don&apos;t try to guess the answer and verify it backward. That approach breaks down on harder variants.
3
Check boundary conditions
Sanity-check with trivial cases: if you start at N in gambler&apos;s ruin, you should already have won (probability 1). If you&apos;ve already seen the target pattern, expected additional flips = 0.
4
Anticipate the follow-up
After you give E[HH] = 6, expect "what about HT?" or "what about HTH?" Practicing a range of patterns is faster than re-deriving the method from scratch each time.

Practice coin flip and probability problems interactively

Get instant feedback on your reasoning process — not just your final answer — from an AI quant interviewer.

Probability Questions →