Skip to content

Commit 785a04d

Browse files
authored
Create Largest Local Values in a Matrix.java
1 parent 4bcd108 commit 785a04d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int[][] largestLocal(int[][] grid) {
3+
int rows = grid.length;
4+
int cols = grid[0].length;
5+
int[][] result = new int[rows - 2][cols - 2];
6+
for (int i = 0; i < rows - 2; i++) {
7+
for (int j = 0; j < cols - 2; j++) {
8+
for (int k = i; k < i + 3; k++) {
9+
for (int l = j; l < j + 3; l++) {
10+
result[i][j] = Math.max(result[i][j], grid[k][l]);
11+
}
12+
}
13+
}
14+
}
15+
return result;
16+
}
17+
}

0 commit comments

Comments
 (0)