July 4th Sale
Limited Time Deal: Unlock all premium questions for over 40% off
$10.42$6.25
10
:
09
:
23
:
30
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.
...