Python Union-Find (+ path compression)
Words are redundant\n\nclass Solution:\n    def findRedundantConnection(self, edges):\n        """\n        :type edges: List[List[int]]\n        :rtype: List[i
Words are redundant\n```\nclass Solution:\n    def findRedundantConnection(self, edges):\n        """\n        :type edges: List[List[int]]\n        :rtype: List[int]\n        """\n        N = len(edges)\n        parent = [i for i in range(N+1)]\n\n        def find(node):\n            if parent[node] == node:\n                return node\n            parent[node] = find(parent[node])\n            return parent[node]\n        \n        def union(node1, node2):\n            root1 = find(node1)\n            root2 = find(node2)\n            if root1 == root2:\n                return False\n            parent[root1] = root2\n            return True\n        \n        for n1, n2 in edges:\n            if not union(n1, n2):\n                return [n1, n2]\n\n```
[]