Can we do this more easily without Union Find?
def redundant_connection(edges):
nodes = set()
result = None
for edge in edges:
if edge[0] in nodes and edge[1] in nodes:
result = edge
else:
nodes.add(edge[0])
nodes.add(edge[1])
return result
Course: Grokking Coding Interview Patterns in Python - AI-Powered Learning for Developers
Lesson: Solution: Redundant Connection - Grokking Coding Interview Patterns in Python