Company: Barclays
Difficulty: medium
On a social networking site every user has a unique profile ID from 0 to users - 1 and a list of friends. A company wants to promote its product on the site: it asks one user to post the promotional message on that user's wall, and that user may then share the message with each of their friends, asking them to post it on their walls as well. Those friends may in turn share it with their friends, and so on. Friendship on this site is one-directional : if user2 is a friend of user1 , it is not necessarily true that user1 is a friend of user2 . A user cannot share the message with a friend who has already received it. The company wants to hand the message to the single user from whom it ends up posted on the maximum number of walls (the starting user's own wall counts too). Print the profile ID of that user. If several users lead to the same maximum number of walls, print the smallest such profile ID. Input The first line contains a single integer users , the number of users N . The secon