Determine Pin Connections Through Common Boards
PinterestData Scientist · OnsiteLast 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.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.