FastPrepCount Communicating Servers
Problems/Count Communicating Servers

Count Communicating Servers

Fox Corporation logoFox Corporation● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report provides the core task and interview context. The callable signature, deterministic output order, examples, and bounds are source-faithful reconstruction details; estimated fidelity is 90%.

A binary matrix represents servers: grid[r][c] = 1 means a server is present. Two servers can communicate when they share a row or column.

Return the number of servers that can communicate with at least one other server.

Function

countCommunicatingServers(grid: int[][]) → int

Examples

Example 1

grid = [[1,0],[0,1]]return = 0

Neither server shares a row or column.

Example 2

grid = [[1,0],[1,1]]return = 3

All three servers communicate.

Example 3

grid = [[1,1,0,0],[0,0,1,0],[0,0,1,0]]return = 4

Every server belongs to a shared row or column.

Constraints

  • 0 <= rows, columns <= 1000.
  • Every cell is 0 or 1.

More Fox Corporation problems

  • Merge Overlapping IntervalsPHONE SCREEN · Seen Sep 2026
  • S-Shaped Matrix TraversalPHONE SCREEN · Seen Sep 2026
  • Find a Peak ElementPHONE SCREEN · Seen Sep 2026
See Fox Corporation hiring insights
Saved
class Solution {
    public int countCommunicatingServers(int[][] grid) {
        // write your code here
    }
}
Checking account…