Most-Connected Non-Friend Pair
Problem
**[Asked at Meta]**
Find the **pair of users (u1 < u2)** who are **not currently friends** but
share the **most mutual friends**.
Return `u1`, `u2`, `mutual_count` for the top pair.
Tables
Example rows — the live problem includes the full dataset.
friendships
| user_id | friend_id |
|---|
Expected output
Your answer should return 1 row with the columns u1, u2, mutual_count.
Starter code (SQL)
SELECT *
FROM friendships;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock