← ALL NOTES
Depth-First Search

684. Redundant Connection

A tree had one extra edge added, creating exactly one cycle; return the edge whose removal restores a tree (the last such edge in input order if there's a choice). Union-Find nails this directly:…

Loading…