Skip to content
LeetQuant
F1 Mathematical Reasoning and Calculus

F1 · Mathematical Reasoning and Calculus · Lesson 6 of 6

Problem-Solving Heuristics: Symmetry, Extremes, Small Cases

Three habits that crack a large share of interview puzzles and catch wrong answers: exploit symmetry, test extreme cases, and solve small cases until the pattern shows.

15 min

Why heuristics

Interview puzzles are designed so that brute-force calculation is slow and a change of viewpoint is fast. Three moves cover a surprising fraction of them, and the same three moves are your best defence against a wrong answer:

  1. Symmetry. If several outcomes are interchangeable, they have equal probability or equal expectation. No calculation needed.
  2. Extremes. Push a parameter to 0, 1 or infinity, or make the problem degenerate. The answer must still make sense there, and often the extreme case is the answer.
  3. Small cases. Solve n=1,2,3,4n = 1, 2, 3, 4 by hand, spot the pattern, then explain why it holds.

Symmetry, precisely

The argument is: find a transformation (relabelling, reflection, rotation) that maps the problem to itself and maps one outcome to another. Then those outcomes have the same probability. Examples:

  • For nn i.i.d. continuous variables, each ordering is equally likely, so P(X1 is the largest)=1nP(X_1 \text{ is the largest}) = \tfrac1n and any specified ordering of kk of them has probability 1k!\tfrac{1}{k!}.
  • For i.i.d. positive X1,…,XnX_1, \dots, X_n, the ratios Xi/∑jXjX_i / \sum_j X_j have the same distribution and sum to 1, so each has mean 1n\tfrac1n, whatever the distribution.
  • Ants on a stick bouncing off each other behave like ants passing through each other, because the ants are indistinguishable for the question asked.

State the transformation out loud. "By symmetry" without saying what is symmetric is how wrong answers get through.

Worked example

the minimum of n uniforms by symmetry

X1,…,XnX_1, \dots, X_n are independent and uniform on [0,1][0, 1]. Find E[min⁡Xi]\mathbb{E}[\min X_i], and more generally the expected value of the kk-th smallest.

Show solution

The nn points cut [0,1][0, 1] into n+1n + 1 gaps G0,G1,…,GnG_0, G_1, \dots, G_n (from 0 to the smallest point, between consecutive points, from the largest point to 1). The gaps sum to 1.

Claim: the gaps are exchangeable. Put n+1n + 1 independent uniform points on a circle of circumference 1, and cut the circle at the first one to make a unit interval. The remaining nn points are independent uniforms on that interval, so the arcs between consecutive points on the circle are exactly our gaps. On the circle, no arc is special, so every gap has the same distribution.

Hence (n+1)E[G0]=1(n + 1)\mathbb{E}[G_0] = 1 and

E[min⁡Xi]=E[G0]=1n+1,E[k-th smallest]=kn+1.\mathbb{E}[\min X_i] = \mathbb{E}[G_0] = \frac{1}{n + 1}, \qquad \mathbb{E}[k\text{-th smallest}] = \frac{k}{n + 1} .

Check against the tail integral from the integration lesson: ∫01(1−x)n dx=1n+1\int_0^1 (1 - x)^n\,dx = \tfrac{1}{n + 1}. The symmetry argument gives every order statistic at once.

Worked example

a rope around the Earth

A rope fits tightly around the equator (radius about 6,400 km). You lengthen it by 1 metre and lift it uniformly off the ground. How high does it sit?

Show solution

Intuition says "imperceptibly". Calculation: circumference C=2πrC = 2\pi r, so adding ΔC\Delta C raises the radius by Δr=ΔC/(2π)=1/(2π)≈0.16\Delta r = \Delta C/(2\pi) = 1/(2\pi) \approx 0.16 m, enough to crawl under.

The extreme-case shortcut. The answer does not depend on rr, since CC is linear in rr. If you suspected that, take the extreme r=0r = 0: a rope of length 1 m laid in a circle has radius 1/(2π)1/(2\pi), so that is the gap for any planet. Letting a parameter go to a degenerate value, when you believe the answer does not depend on it, often finishes the problem.

The extreme-case check. The same move audits claimed answers. Someone asserts E[max⁡ of n uniforms]=1−1n\mathbb{E}[\max \text{ of } n \text{ uniforms}] = 1 - \tfrac1n; at n=1n = 1 that gives 0, but a single uniform has mean 12\tfrac12. The formula is dead in one line.

Worked example

100 lockers

100 lockers start closed. Person kk, for k=1,…,100k = 1, \dots, 100, toggles every locker whose number is a multiple of kk. How many lockers are open at the end?

Show solution

Small cases. With 10 lockers, run it by hand: lockers 1, 4 and 9 end open. That suggests perfect squares.

Why. Locker mm is toggled once for each divisor of mm, so it ends open exactly when mm has an odd number of divisors. Divisors pair up as d↔m/dd \leftrightarrow m/d, and the pairing fails only when d=m/dd = m/d, i.e. mm is a perfect square. So the open lockers are 1,4,9,…,1001, 4, 9, \dots, 100: there are 10.

The order matters: the small cases gave a conjecture in a minute; the pairing argument turned it into an answer you can defend. Never stop at the pattern.

Doing this out loud

A good interview answer follows a visible pattern:

  1. Restate the problem and name the quantity you want.
  2. Say which heuristic you will try first ("these five are i.i.d., so I'll look for a symmetry").
  3. If stuck, shrink it: "let me do it with two players first".
  4. Before announcing an answer, test one extreme: probability at p=0p = 0 or 1, a single item, a degenerate shape.
  5. Give the answer, with the one-sentence reason it is right.

Interviewers routinely give hints; a candidate who has shown which heuristics they are trying is far easier to help.

Knowledge check

A stick of length 1 is broken at two independent uniform points. What is the expected length of the leftmost piece?

Knowledge check

X1,…,X5X_1, \dots, X_5 are i.i.d. continuous. What is P(X3 is the largest and X1 is the smallest)P(X_3 \text{ is the largest and } X_1 \text{ is the smallest})?

Knowledge check

A colleague claims that the expected maximum of nn i.i.d. uniforms on [0,1][0, 1] is 1−1n1 - \tfrac1n. Which observation refutes this fastest?

Key takeaways

  • Symmetry: name the transformation that swaps outcomes, then equal outcomes get equal probability.
  • nn uniform points make n+1n + 1 exchangeable gaps, so the kk-th smallest has mean kn+1\tfrac{k}{n + 1}.
  • Extremes: if the answer should not depend on a parameter, set it to a degenerate value; always test a claimed formula at n=1n = 1, p=0p = 0 or p=1p = 1.
  • Small cases give conjectures in minutes; follow up with a reason (pairing, induction, an invariant).
  • Narrate which heuristic you are trying; it makes you easier to hint and harder to misjudge.

Practice problems

Finished reading?

Answer the 3 knowledge checks to complete this lesson (0 done).