Problem 547 · Medium

Number of Provinces

Count connected components using Union-Find.

Open the interactive visualisation