Two Decks Turned Over Together
The classic matching-problem puzzle — two shuffled decks flipped one card at a time, asking for the expected number of positions where the cards match — solved cleanly with linearity of expectation.
Problem. Take two separate, independently shuffled 52-card decks. Lay them side by side and flip one card from each deck at a time, comparing the two cards at each of the 52 positions. What's the expected number of positions where the two cards match exactly (same rank and suit)?
This is the classic "matching problem" (also called the derangement or coincidence problem), and it has a reputation for being intimidating because the "obvious" approach — trying to compute the full probability distribution of the match count — is genuinely hard. The trick that makes it easy is to never touch that distribution at all.
The trick: linearity of expectation, indicator by indicator
Define an indicator variable for each position , equal to 1 if the two cards at position match, and 0 otherwise. The total number of matches is , and
In plain English: the expected total number of matches is just the sum of the expected values of each individual position's match indicator — and crucially, this identity is true regardless of whether the positions are independent of each other. That's the entire reason this problem, which looks like it needs a complicated joint distribution, collapses to simple arithmetic.
Computing one term
For any single position , deck two's card at position is equally likely to be any of the 52 cards, and there's exactly one card in deck one it needs to match. So
for every position , regardless of what happened at other positions.
Putting it together
You expect exactly one match between the two decks, on average, no matter how the decks are shuffled or correlated with each other in some other way — as long as each individual position is a uniformly random pairing. This is a strikingly clean answer for a question that sounds like it should depend on all 52 cards' joint behavior, and it's exactly why interviewers love this puzzle: it rewards recognizing that linearity of expectation sidesteps dependence entirely, rather than rewarding brute-force combinatorics.
Worked example: the same trick with a smaller deck
To build confidence, shrink the problem to cards instead of 52. By the same logic, for each of the 4 positions, so — still exactly one expected match, regardless of . This is the signature of the matching problem: the expected number of matches is always 1, for any deck size , because and there are positions, so the always cancels.
For "how many positions match" problems, define one 0/1 indicator per position, note that each has expectation by symmetry, and sum: . This works regardless of dependence between positions — linearity of expectation never requires independence, only that you sum expectations rather than trying to derive the full joint distribution.
Whenever an interview question asks for "expected number of positions/pairs/people with property " and the underlying randomness is a permutation or shuffle, try an indicator-variable decomposition before attempting anything else. It almost always turns a hard combinatorics problem into a one-line sum.
Don't confuse "expected number of matches is 1" with "the probability of at least one match is high." As deck size grows, the probability of zero matches converges to — meaning roughly a third of the time you'll see no matches at all, even though the average across many trials is exactly one. Expectation and typical outcome are not the same thing here.
Related concepts
Practice in interviews
Further reading
- Ross, A First Course in Probability, ch. 7