Servers Whose Failure Splits the Network
Implement keyServers
A network of servers is joined by cables (an undirected graph given as an adjacency list). A server is a key server if taking it out, together with its cables, leaves the remaining servers split into more separate parts than before. Find all key servers.
Removing each server and searching again works, but Tarjan's algorithm finds all of them in one depth-first search, again using discovery times and low-link values, with a slightly different test than for bridges and a special rule for the root.
Example 1:
Input: graph = [[1,2],[0,2],[0,1,3],[2,4,5],[3,5],[3,4,6],[5]]
Output: [2,3,5]
Example 2:
Input: graph = [[1],[0,2],[1]]
Output: [1]
Example 3:
Input: graph = [[1,2],[0,2],[0,1]]
Output: []
+ 15 hidden test cases run on Submit.
Constraints:
- ●
1 ≤ n ≤ 8 servers numbered 0 … n-1; graph[u] lists, in increasing order, every server joined to u by a cable (adjacency-list form of an undirected graph) - ●
If v is in graph[u] then u is in graph[v]; there are no cables from a server to itself and no repeated cables - ●
The network may consist of several separate parts - ●
A server is a key server (articulation point) when taking it out of the network, together with its cables, increases the number of separate parts among the remaining servers. Return all key servers in increasing order
graph =