← Two Sigma Interview Insights
I spent the first few minutes thinking about this combinatorially in a way that was going nowhere.
Use linearity of expectation by defining an indicator for each unordered pair of vertices being a good pair. For a fixed pair {u,v}, compute the probability that u is v's maximum-weight neighbor and v is u's maximum-weight neighbor, leveraging symmetry and the continuous distribution of edge weights. Then multiply by the number of pairs to get the expected number.
Pro tip: Emphasize that the specific continuous distribution doesn't matter—only that ties have probability zero and all edge weights are i.i.d. This shows you understand the robustness of the result and can simplify the problem.
For each unordered pair {u,v}, let I_{uv} be 1 if u and v are each other's maximum-weight neighbor, else 0. Then the total number of good pairs is the sum of I_{uv} over all pairs.
The expected number of good pairs is the sum of E[I_{uv}] over all pairs. By symmetry, E[I_{uv}] is the same for every pair, so the expectation equals C(n,2) times the probability that a fixed pair is good.
Fix vertices u and v. For u to be v's maximum-weight neighbor, the edge (u,v) must have weight greater than all other edges incident to v. Similarly, for v to be u's maximum-weight neighbor, (u,v) must be greater than all other edges incident to u. These conditions involve disjoint sets of edges (except the shared edge (u,v)), so they are independent given the weight of (u,v).
Condition on the weight w of edge (u,v). The probability that (u,v) is the maximum among the n-1 edges incident to v is 1/(n-1) (by symmetry, since all n-1 edges are i.i.d.). Similarly for u. Since the events are independent given w, the conditional probability is 1/(n-1)^2. This does not depend on w, so the unconditional probability is also 1/(n-1)^2.
The expected number of good pairs is C(n,2) * 1/(n-1)^2 = [n(n-1)/2] / (n-1)^2 = n / (2(n-1)).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.