Find the Influencer or Celebrity - Algorithms and Problem SolvingAlgorithms and Problem Solving
Posted on A celebrity/influencer is a person who doesn't anybody but is known to or followed by everybody. Given N peoples and a matrix for known or following information then find the celebrity or influencer among the group of N peoples. Formally speaking, Given a matrix of following between N users (with ids from 0 to N-1): * following[i][j] == true iff user i is following user j * thus following[i][j] doesn't imply following[j][i]. * Let's also agree that followingMatrix[i][i] == false * * – followed by everyone else and * – not following anyone himself * Find an Influencer by a given matrix of following, * or return -1 if there is no Influencer in this group. For example, Lets suppose we have N=5 peoples {A,B,C,D,E} and the following matrix is as follows – following[0][3] = 1; following[0][1] = 1; following[1][3] = 1; following[1][0] = 1; following[1][4] = 1; following[4][3] = 1; following[2][3] = 1; following[2][4] = 1; then clearly 3 is celebrity.Read full article from Find the Influencer or Celebrity - Algorithms and Problem SolvingAlgorithms and Problem Solving
No comments:
Post a Comment