Tap here to switch tabs
Problem
Submissions

Problem: Count Servers that Communicate

med
30 min
Try to solve the Count Servers that Communicate problem.

Statement

You are given a binary matrix grid with m rows and n columns. A cell value of 11 represents a server, and a cell value of 00 represents an empty cell.

Two servers can communicate if they are located in the same row or in the same column. A server is considered communicating if it can communicate with at least one other server.

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

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤1 \leq m ≤250\leq 250

  • 1≤1 \leq n ≤250\leq 250

  • grid[i][j] == 0 or grid[i][j] == 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Servers that Communicate

med
30 min
Try to solve the Count Servers that Communicate problem.

Statement

You are given a binary matrix grid with m rows and n columns. A cell value of 11 represents a server, and a cell value of 00 represents an empty cell.

Two servers can communicate if they are located in the same row or in the same column. A server is considered communicating if it can communicate with at least one other server.

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

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤1 \leq m ≤250\leq 250

  • 1≤1 \leq n ≤250\leq 250

  • grid[i][j] == 0 or grid[i][j] == 1