Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04000c5

Browse files
refactor 1267
1 parentad21bce commit04000c5

File tree

1 file changed

+3
-34
lines changed

1 file changed

+3
-34
lines changed

‎src/main/java/com/fishercoder/solutions/_1267.java

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
11
packagecom.fishercoder.solutions;
22

3-
importcom.fishercoder.common.utils.CommonUtils;
4-
5-
/**
6-
* 1267. Count Servers that Communicate
7-
*
8-
* 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.
9-
* Two servers are said to communicate if they are on the same row or on the same column.
10-
*
11-
* Return the number of servers that communicate with any other server.
12-
*
13-
* Example 1:
14-
* Input: grid = [[1,0],[0,1]]
15-
* Output: 0
16-
* Explanation: No servers can communicate with others.
17-
*
18-
* Example 2:
19-
* Input: grid = [[1,0],[1,1]]
20-
* Output: 3
21-
* Explanation: All three servers can communicate with at least one other server.
22-
*
23-
* Example 3:
24-
* Input: grid = [[1,1,0,0],[0,0,1,0],[0,0,1,0],[0,0,0,1]]
25-
* Output: 4
26-
* Explanation: The two servers in the first row can communicate with each other.
27-
* 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.
28-
*
29-
* Constraints:
30-
* m == grid.length
31-
* n == grid[i].length
32-
* 1 <= m <= 250
33-
* 1 <= n <= 250
34-
* grid[i][j] == 0 or 1
35-
* */
363
publicclass_1267 {
374
publicstaticclassSolution1 {
38-
/**credit: https://leetcode.com/problems/count-servers-that-communicate/discuss/436188/Java-or-Clean-And-Simple-or-Beats-100*/
5+
/**
6+
* credit: https://leetcode.com/problems/count-servers-that-communicate/discuss/436188/Java-or-Clean-And-Simple-or-Beats-100
7+
*/
398
publicintcountServers(int[][]grid) {
409
intm =grid.length;
4110
intn =grid[0].length;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp