Clusters of Linked Servers
Medium · Clusters of Linked Servers
A data centre has `n` servers numbered from 0 to n − 1. The n × n matrix `links` describes the cables: `links[i][j] = 1` if servers `i` and `j` are wired directly, and 0 otherwise. Every link works both ways, and each server counts as linked to itself. Servers that can reach each other through cables (directly or via other servers) belong to the same cluster. Return the number of clusters.…
Solve the problem →