Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 2316. Count Unreachable Pairs of Nodes in an Undirected Graph
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.