Shortest Distance Between Two Pins via Shared Boards

Asked at Pinterest · Coding Questions · Difficulty: Medium · Last asked Mar 15, 2026

A content-sharing service groups pins into boards. Two pins are related when at least one board contains both of them, and a chain of related pins connects pins that never share a board directly. Given the boards, find how closely two pins are connected.

Loading the problem…