Components over Time — Solution & Editorial
Union-find: each successful union decreases the count by one; self-loops and repeats change nothing.
Complexity: O(M α(N))
Union-find: each successful union decreases the count by one; self-loops and repeats change nothing.
Complexity: O(M α(N))