Open zhangbo2008 opened 2 years ago
对,这里有问题,应该是: if uf.count[proot ] == len(uf.parent)-1 { //proot is the root of the tree, no need to merge } else if uf.count[qroot] == len(uf.parent)-1 { proot , qroot = qroot, proot } else if uf.count[qroot] > uf.count[proot] { proot , qroot = qroot, proot }
呵呵,来信收到,谢谢
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
@zhangbo2008 我这里的 proot 和 qroot 只是代表 index,存的 count 是在 uf.count[proot] 中。
https://github.com/halfrost/LeetCode-Go/blob/f0792d1179b1a6ab12fb9f906a3fc40ef68f9a80/template/UnionFind.go#L104
感觉这个地方应该是:
应该是 uf.count[proot]== len(uf.parent)-1