Google Phone Screen graph question
Anonymous User
1427

Was asked to design a graph problem similar to what we have on Linkedin

given a function getFriend(int user) which returns all the users 1st degree friends, write a function to check:

  1. whether two users are first-level, second-level and third-level connections
  2. function that outputs a users 2nd degree and 3rd degree friends

EDIT: there was also a followup:

Find all 2nd degree connections but output the connections sorted by the number of common friends with you,
Example: if 2nd degree connection A has 10 common friends (1st degree connections) with you but 2nd degree connection B has 8 common friends
(1st degree connections)with you, then A should be ranked first)

Comments (3)