Summer Sale
Limited Time Deal: Unlock all premium questions for over 30% off
14
:
03
:
44
:
08
Degrees of Separation
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.
...
OfferRetriever
Master technical interviews with real questions from top companies. Build your confidence and career.
LEGAL
© 2026 Purple Business Holdings LLC. All rights reserved. See Terms of Service.