← Snapchat Interview Insights

Snapchat·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Snapchat software engineering interview that leaned heavily into statistical intuition. The question felt more like a math/ML theory check than a coding round, which threw me a bit.

Questions Asked (1)

Q1

Why does the median minimize the sum of absolute deviations (L1) while the mean minimizes the sum of squared deviations (L2)? Walk through the intuition and a rough derivation. Then extend this to picking an optimal point in 2D under Manhattan vs Euclidean distance, and explain when the mean becomes a bad estimator because of outliers.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I knew the punchline but fumbled the derivation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the intuition behind why the median minimizes L1 and the mean minimizes L2 using simple examples and geometric interpretations. Then provide a rough derivation using calculus (derivative of the loss function) to show the optimality conditions. Finally, extend to 2D with Manhattan and Euclidean distances, and discuss how outliers affect the mean's robustness.

Pro tip: Mention that the median is robust to outliers because it depends only on the order of values, while the mean is sensitive to extreme values. This ties into real-world applications like robust statistics and choosing appropriate loss functions in machine learning.

1. Intuition for 1D

Explain that for L1, moving the estimate towards a data point reduces the sum of absolute deviations until you hit the median; for L2, the squared penalty makes the mean the balance point.

2. Rough Derivation

Show that the derivative of sum |x_i - c| is the sum of signs, which is zero when equal numbers of points are on each side (median). For L2, derivative of sum (x_i - c)^2 is -2 sum (x_i - c), zero when c is the mean.

3. Extension to 2D

For Manhattan distance, the optimal point minimizes sum of L1 distances; the solution is the geometric median (not necessarily a data point). For Euclidean distance, it's the centroid (mean).

4. Outlier Sensitivity

Explain that the mean is not robust: a single outlier can pull it arbitrarily far, while the median remains stable. This makes the mean a bad estimator when data has outliers or heavy tails.

5. Practical Implications

Discuss when to use each: L1/median for robust estimation, L2/mean for efficiency under Gaussian noise. Mention applications like regression (LAD vs OLS) and clustering (K-medians vs K-means).

Key Points to Mention

  • Median minimizes sum of absolute deviations (L1 norm).
  • Mean minimizes sum of squared deviations (L2 norm).
  • Derivative of L1 loss involves sign function; zero when equal points on each side.
  • Derivative of L2 loss is linear; zero at the mean.
  • In 2D, Manhattan distance optimal point is geometric median; Euclidean distance optimal point is centroid.
  • Mean is sensitive to outliers; median is robust.

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