NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

In a social network, you are tasked with building a friend recommendation system. Given the number of users n, and a list of existing friendship pairs friendships, your goal is to recommend one new friend for each user.

For each user i (indexed from 0 to n - 1), you need to find the best-recommended friend based on the following rules, in order of priority:

Test Cases
Input
Output
Expected