101
0/304
Loading content...
A social graph analytics pipeline stores friendship edges in canonical form and needs to identify unusually well-connected friend pairs.
Table: Friendship
Data guarantees:
Definitions:
Task: For every friendship pair already present in the Friendship table, compute its number of mutual friends and return only the pairs whose count is at least 3.
Output requirements:
Supported submission environments:
Friendship:
| user1_id | user2_id |
|----------|----------|
| 1 | 2 |
| 1 | 3 |
| 2 | 3 |
| 1 | 4 |
| 2 | 4 |
| 1 | 5 |
| 2 | 5 |
| 1 | 6 |
| 2 | 6 |
| 1 | 7 |
| 3 | 7 |
| 3 | 6 |[
{"user1_id":1,"user2_id":2,"common_friend":4},
{"user1_id":1,"user2_id":3,"common_friend":3}
]Pair (1,2) shares {3,4,5,6}. Pair (1,3) shares {2,6,7}. Other friendship pairs in this input do not reach 3 mutual friends.
Friendship:
| user1_id | user2_id |
|----------|----------|
| 10 | 11 |
| 11 | 12 |
| 12 | 13 |
| 13 | 14 |
| 14 | 15 |[]This path-shaped graph has no friendship edge whose endpoints share 3 or more mutual friends.
Friendship:
| user1_id | user2_id |
|----------|----------|
| 20 | 21 |
| 20 | 22 |
| 21 | 22 |
| 20 | 23 |
| 21 | 23 |
| 20 | 24 |
| 21 | 24 |
| 20 | 25 |
| 21 | 25 |
| 22 | 23 |[
{"user1_id":20,"user2_id":21,"common_friend":4}
]Users 20 and 21 are directly connected and share mutual friends {22,23,24,25}, so their overlap count is 4.
Constraints