Initialize DSU with nodes, count = n.
Iterate through the matrix isConnected[i][j].
If isConnected[i][j] = 1 and find(i) != find(j), union them and decrement count.
Return count.
Each successful union reduces components by one. Final count is the number of provinces. Time: due to matrix traversal. Space: for the DSU arrays. You could also solve this with DFS or BFS, but DSU is cleaner here.