原题如下:Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.
感觉非常直观的一道Union-Find的题目,但是有一个test case 中的输出值竟然为负数,百思不得其解,求大神提点我一下哪里出了问题,谢谢。
代码如下:
public class Solution {
public int CountComponents(int n, int[][] edges) {