Algorithm · LinkedIn · Medium
Given two members of a professional network, determine how many connection steps separate them. Model the network as a graph in which each vertex represents a user and each edge represents a connection. Beginning at the first user, perform a breadth-first search (BFS) until the other user is reached, then report their connection distance. Input Identifier for the source user Identifier for the destination user A collection of user-to-user connections represented as ID pairs…
Checking your access…