Available question text
Given an undirected graph, count the number of unordered node pairs that are unreachable from each other — equivalently, pairs that lie in different connected components. Compute sizes of connected components and use combinatorics (sum of products of component sizes) in O(n + m) time (e.g., via DFS/BFS or Union-Find) to handle up to 1e5 nodes/edges.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2316. Count Unreachable Pairs of Nodes in an Undirected Graph
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source