1951. All the Pairs With the Maximum Number of Common Followers
Description
+-------------+------+
| Column Name | Type |
+-------------+------+
| user\_id | int |
| follower\_id | int |
+-------------+------+
(user\_id, follower\_id) is the primary key for this table.
Each row of this table indicates that the user with ID follower\_id is following the user with ID user\_id.Relations table:
+---------+-------------+
| user\_id | follower\_id |
+---------+-------------+
| 1 | 3 |
| 2 | 3 |
| 7 | 3 |
| 1 | 4 |
| 2 | 4 |
| 7 | 4 |
| 1 | 5 |
| 2 | 6 |
| 7 | 5 |
+---------+-------------+
Result table:
+----------+----------+
| user1\_id | user2\_id |
+----------+----------+
| 1 | 7 |
+----------+----------+
Users 1 and 2 have 2 common followers (3 and 4).
Users 1 and 7 have 3 common followers (3, 4, and 5).
Users 2 and 7 have 2 common followers (3 and 4).
Since the maximum number of common followers between any two users is 3, we return all pairs of users with 3 common followers, which is only the pair (1, 7). We return the pair as (1, 7), not as (7, 1).
Note that we do not have any information about the users that follow users 3, 4, and 5, so we consider them to have 0 followers.ac
Last updated