Remove Max Number of Edges to Keep Graph Fully Traversable
HardLeetCodeUnion-Find (DSU)
Approach hintTry it first, then revealHide
Keep one DSU for Alice and one for Bob. Add shared type-3 edges to both first, then each person's own edges; count edges that join nothing new, and return -1 if either DSU ends up disconnected.