Katkat

Determine Pin Connections Through Common Boards

PinterestData Scientist · Onsite

Last updated

This question evaluates graph modeling and connectivity concepts, including representing boards and pins as relationships and reasoning about reachability and minimal connection paths.

Scenario

Pinterest boards contain many pins; need to infer relationships between pins.

Question

Given the membership lists of all boards, write a function that returns whether two pins are connected through any sequence of common boards. Follow-up: return the minimum number of boards required to connect the two pins.

Hints

Model boards/pins as a bipartite graph; BFS from one pin over boards to the other.