LOKBIL - Editorial

PROBLEM LINKS

Practice
Contest

DIFFICULTY

EASY

EXPLANATION

Most of the people helped our cook to find the most popular friend and he is very happy now. Facebook walls didn’t get spammed. But some of you got stuck in finding him, and thus, our cook wants to explain how to find " the most popular friend". It’s quite simple, create a matrix of friends such that if ‘i’ is a friend of ‘j’ then friend[i][j] =1, else friend[i][j]=0. Now, run Breadth First Search on each friend to find the distances of each friend from him. After finding this, calculate the average distance of everyone from him. After calculating it for all, print the friend with the smallest average. Yes, he is the one.

SETTER’S SOLUTION

Can be found here.

TESTER’S SOLUTION

Can be found here.

1 Like