leetcode| 323. Number of Connected Components in an Undirected Graph(并查集/DFS/BFS)

题目 题目描述:一张含n节点的无向图,以及一组无向边,编写一个函数来查找无向图中链接的组件的数量。web Input: n = 5 and edges = [[0, 1], [1, 2], [3, 4]] 0 3 | | 1 --- 2 4 Output: 2 分析 解法DFS/BFS/并查集,DFS和BFS时间复杂度均
相关文章
相关标签/搜索