shlogg · Early preview
Md Ariful Haque @mah-shamim

Counting Communicating Servers In Grids

Two servers can communicate if they're in the same row or column. Count servers that can talk to others by counting rows and columns with multiple servers.

1267. Count Servers that Communicate
Difficulty: Medium
Topics: Array, Depth-First Search, Breadth-First Search, Union Find, Matrix, Counting
You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column.
Return the number of servers that communicate with any other server.
Example 1:


Input: grid = [[1,0],[0,1]]
Output: 0
Explanation: No servers can communicate with others.

Example 2:


Input: grid = [[...