Problem: Number of Provinces Task: Given the connection matrix of cities, count connected components. This is DSU's bread and butter. Process all connections, union connected cities, and count how many distinct leaders remain.
Alternatively, start with count = and decrement on each successful union. The input is an adjacency matrix, so you check isConnected[i][j] for all pairs. Only process pairs where to avoid duplicate unions.