Best Friend
Best friend: is a friend in one’s list who likes his content the most.
Using Jack as an example, Jack likes Rachel’s post 5 times, but 0 for Mark, so Jack is Rachel’s best friend.
Rachel’s best friend is Ellen.
Return this JSON object:
{"user 1": ["user 2", "1 likes 2", "2 likes 1"],
...
}
This problem asks you to determine each user’s best friend: the friend in their list who likes their content the most. The key is to model the relationships and like counts cleanly, typically with hash maps or adjacency structures that record how many times one user likes another user’s posts. Then, for each person, scan their friends and choose the one with the highest like count. It is essentially a graph/relationship-counting problem where careful data aggregation matters most.