Number of Provinces — Union-Find

Count the groups of cities in a road-link table that can reach each other through chains of roads, with each isolated city its own group.

Union-Find · Easy

More in Union-Find

All algorithm problems