</>OfferRetriever
DashboardDiscuss
NEW

Spring Hire Sale

Limited Time Deal: Unlock all premium questions for over 30% off

$10.42$7.08

08

:

03

:

07

:

58

Get this deal
Back to Dashboard

Unfriended Pairs Counter

Medium
FREE

In a social network of n people labeled 0 to n - 1, friendship is mutual and transitive through direct connections. People belong to the same friend group (connected component) when a chain of direct friendships links them.

Given a list of direct connections (pairs [a, b]), count the number of unordered pairs (i, j) where 0 <= i < j < n such that i and j are not in the same friend group. ...