All tasks

Friends of Friends (Social Graph)

Advanced

Meta/LinkedIn level task. **Condition:** Find for each user the "friends of friends" โ€” people who are followed by their follows, excluding direct friends and the user themselves. **Table:** follows (follower_id, following_id, created_at) **Requirements:** 1. For each user, find their follows (1st level) 2. Find the follows of their follows (2nd level) 3. Exclude direct follows and the user themselves 4. Output user_id, friend_of_friend_id, via whom they are connected (via_user_id) **Hint

Category
Recursive CTE
Estimated time
~25 min
Databases
PostgreSQLGreenplum
Tags
FAANGInterviewSocial GraphFriendsNetworkั€ะตะบัƒั€ัะธั

Sign in to solve

Start Solving