Podcast Pairs Sharing the Most Subscribers
Problem
Table: `subscriptions`
| Column Name | Type |
|---|---|
| podcast_id | int |
| listener_id | int |
`(podcast_id, listener_id)` is the primary key. Each row means the listener subscribes to that podcast.
Find every pair of podcasts that share the maximum number of common subscribers. If the largest number of subscribers shared by any two podcasts is `maxShared`, return all podcast pairs that share exactly `maxShared` subscribers. In each returned pair the smaller `podcast_id` must appear first, in columns `podcast1_id` and `podcast2_id`. Return the result in any order.
Tables
Example rows — the live problem includes the full dataset.
| podcast_id | listener_id |
|---|---|
| 1 | 10 |
| 2 | 10 |
| 1 | 11 |
Expected output
Your answer should return 1 row with the columns podcast1_id, podcast2_id.
Starter code (SQL)
SELECT *
FROM subscriptions;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