package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

684. Redundant Connection

Solution idea

UnionFind 基础题

  • 遍历每一条边
    • 如果这条边两端的节点已经有同一个祖宗, 说明已经连接过, 当前的边会导致成环
    • 如果不是, 两端节点联姻 (ie. 加入同一集合/同一根节点)

Time complexity = $O(n)$

Resource

【每日一题】684. Redundant Connection, 10/01/2019

代码随想录-684.冗余连接

time complexity analysis