未验证 提交 d5b5f573 编写于 作者: L LEO D PEN 提交者: GitHub

Update UnionFind算法应用.md

上级 df911664
......@@ -317,7 +317,7 @@ class Solution {
public boolean validTree(int n, int[][] edges) {
// 树的特性:节点数 = 边数 + 1
if (edges.length != n - 1) return false;
graph_261.Solution.DisjointSet djs = new graph_261.Solution.DisjointSet(n);
DisjointSet djs = new DisjointSet(n);
for (int[] edg : edges) {
// 判断连通情况(如果合并的两个点在一个连通分量里,说明有环)
if (!djs.union(edg[0], edg[1])) return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册