Medium
,DFS
,BFS
,Graph
2316. Count Unreachable Pairs of Nodes in an Undirected Graph
You are given an integer n
. There is an undirected graph with n
nodes, numbered from 0
to n - 1
. You are given a 2D integer array edges where edges[i]
= [, ] denotes that there exists an undirected edge connecting nodes and .
Return the number of pairs of different nodes that are unreachable from each other.
Example 1:
Example 2:
Constraints:
n
<= 105edges.length
<= 2 * 105edges[i].length
== 2n
Yen-Chi ChenSat, Mar 25, 2023
Ron ChenSat, Mar 25, 2023
MarsgoatMar 26, 2023