</>OfferRetriever
DashboardDiscuss
NEW
Halloween SalePremium questions, over 30% offUnlock all premium questions for over 30% off
$10.42$7.08/mo

--

:

--

:

--

:

--

Get this deal
Back to Pinterest Questions

Degrees of Separation

Medium

In a social network, there are n users numbered from 0 to n - 1. You are given a list of bidirectional friend connections connections, where each element [a, b] means user a and user b are friends. The degree of separation between two users is the minimum number of friend hops needed to get from one to the other.

Given n, connections, userA, and userB, return the minimum number of friend hops between userA and userB. Return 0 if userA == userB. Return -1 if no path exists. ...

Asked at:Pinterest

More Pinterest interview questions

All Pinterest interview questions
OfferRetriever

Master technical interviews with real questions from top companies. Build your confidence and career.

PRODUCT
PricingDashboardDiscussOfferRetriever vs LeetCodeCompare
LEGAL

© 2026 Purple Business Holdings LLC. All rights reserved. See Terms of Service.