Skip to content

Instantly share code, notes, and snippets.

@joakin
Last active June 1, 2018 12:33
Show Gist options
  • Save joakin/96335db87507ad9a35a3264a88aecad3 to your computer and use it in GitHub Desktop.
Save joakin/96335db87507ad9a35a3264a88aecad3 to your computer and use it in GitHub Desktop.
Common friends - coding exercise

Common friends - coding exercise

Imagine we have data for users of a social network. Users can befriend other users of the network.

We want to implement a feature where a user Alice visiting another user Bob, would see which friends Alice and Bob have in common.

Write a script/function/program in your preferred programming language that takes two user names and gives back a list of the common friends between those users.

Users data

You can get the data for the users from:

The data follows this format:

[ { "id": 5, "name": "Alice", "friends": [ 4, 6 ] }
, { "id": 9, "name": "Bob",   "friends": [ 6, 8 ] }
]

Problem:

  • Find common friends between "Herminia Wyman" and "Melisa Lowe"

Time constraint

We will aim to spend ~25' on this, so try to get to a solution first, and worry about other things later. Please try to speak up as you go trying to explain why and what you are doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment