← Yahoo Interview Insights

Yahoo·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Got pulled into a probability question mid design review at Yahoo, which I was not expecting from a PM. It was framed as a quick gut check but ended up being more involved than it sounded.

Questions Asked (1)

Q1

You flip a fair coin over and over until you see Heads followed immediately by Tails. How many flips should you expect to need on average?

Product Analytics & MetricsAlgorithms & Data Structures
Author's notes

I stared at this for a second because it looks like a simple probability problem but it really isn't.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the process as a Markov chain with states representing the progress toward the pattern (no progress, just saw H). Set up equations for the expected number of flips from each state and solve them. Alternatively, use the general formula for expected waiting time for a pattern in i.i.d. sequences.

Pro tip: Mention that the expected waiting time for HT is 4 flips, while for HH it is 6 flips, to show you understand that overlapping patterns have longer waiting times. This demonstrates deeper insight into pattern matching in random sequences.

1. Define states

Identify the relevant states based on the last flip(s): state 0 = no progress (last flip was T or start), state 1 = last flip was H (so we are one T away from completing HT).

2. Set up equations

Let E0 be the expected additional flips from state 0, and E1 from state 1. Write equations: E0 = 1 + 0.5 E0 + 0.5 E1, and E1 = 1 + 0.5 E1 + 0.5 * 0 (since T completes the pattern).

3. Solve the equations

From E1 = 1 + 0.5 E1, we get E1 = 2. Substitute into E0: E0 = 1 + 0.5 E0 + 1, so 0.5 E0 = 2, giving E0 = 4.

4. Interpret the result

The expected number of flips starting from scratch (state 0) is 4. This is the answer.

5. Optional: Verify with alternative method

Use the formula for expected waiting time for a pattern: for HT, it's 1/(0.5*0.5) = 4, since there is no overlap. This confirms the result.

Key Points to Mention

  • Markov chain states based on recent history
  • Expected value equations and solving linear equations
  • Overlapping vs non-overlapping patterns (HT vs HH)
  • General formula for expected waiting time for a pattern
  • Fair coin implies equal probabilities for H and T
  • Independence of coin flips

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.