A walkthrough of LeetCode problem #1917 (Find Users With Valid E-Mails / Friends Recommendation), one of the hardest SQL problems with only 27% acceptance rate. The solution is built step-by-step in PostgreSQL/pgAdmin using CTEs, self-joins, GROUP BY with HAVING, and UNION to find pairs of users who listened to 3+ common songs on the same day and are not already friends, then returning bidirectional recommendations.

22m watch time
1 Impression