LeetCode-Go icon indicating copy to clipboard operation
LeetCode-Go copied to clipboard

a problem with code

Open zhangbo2008 opened this issue 4 years ago • 4 comments

https://github.com/halfrost/LeetCode-Go/blob/f0792d1179b1a6ab12fb9f906a3fc40ef68f9a80/template/UnionFind.go#L104

感觉这个地方应该是:

应该是 uf.count[proot]== len(uf.parent)-1

zhangbo2008 avatar Nov 24 '21 13:11 zhangbo2008

对,这里有问题,应该是: 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 }

hekai000 avatar Sep 20 '24 09:09 hekai000

呵呵,来信收到,谢谢

haowan1015 avatar Sep 20 '24 09:09 haowan1015

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

xiaokuer avatar Sep 20 '24 09:09 xiaokuer

@zhangbo2008 我这里的 proot 和 qroot 只是代表 index,存的 count 是在 uf.count[proot] 中。

halfrost avatar Sep 22 '24 19:09 halfrost