Friend Recommendations is the library behind a small social app. It tracks friendships, blocked users, and deactivated accounts. Each user is an integer id, and the social graph is loaded from a text file of changes applied in order.
The round has four phases:
recommend(graph, user, k=5), which suggests people by mutual friend count.The code is small, and the Phase 2 algorithm is the familiar friends-of-friends count. What trips people up is the product rules. Blocks apply in both directions, deactivated accounts vanish, and a mutual friend only counts if both people can see them.
Phase 3 then turns on one question you have to answer exactly: when a single edge changes, whose recommendations can change with it?