Problems > Independent Cycles > Editorial

Independent Cycles — Solution & Editorial

Back to the Problem

Every edge that joins two already-connected vertices adds one independent cycle. Union-find counts exactly those: answer = M − (successful unions).

Complexity: O(M α(N))