Skip to content

Commit e0cc1d5

Browse files
add skeleton for 1267
1 parent 9d6cb0c commit e0cc1d5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.fishercoder.solutions;
2+
3+
/**
4+
* 1267. Count Servers that Communicate
5+
*
6+
* 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.
7+
* Two servers are said to communicate if they are on the same row or on the same column.
8+
*
9+
* Return the number of servers that communicate with any other server.
10+
*
11+
* Example 1:
12+
* Input: grid = [[1,0],[0,1]]
13+
* Output: 0
14+
* Explanation: No servers can communicate with others.
15+
*
16+
* Example 2:
17+
* Input: grid = [[1,0],[1,1]]
18+
* Output: 3
19+
* Explanation: All three servers can communicate with at least one other server.
20+
*
21+
* Example 3:
22+
* Input: grid = [[1,1,0,0],[0,0,1,0],[0,0,1,0],[0,0,0,1]]
23+
*
24+
* Output: 4
25+
* Explanation: The two servers in the first row can communicate with each other.
26+
* The two servers in the third column can communicate with each other. The server at right bottom corner can't communicate with any other server.
27+
*
28+
* Constraints:
29+
* m == grid.length
30+
* n == grid[i].length
31+
* 1 <= m <= 250
32+
* 1 <= n <= 250
33+
* grid[i][j] == 0 or 1
34+
* */
35+
public class _1267 {
36+
public static class Solution1 {
37+
public int countServers(int[][] grid) {
38+
return -1;
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)