We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e3a7261 commit 29a84c0Copy full SHA for 29a84c0
2373. Largest Local Values in a Matrix
@@ -0,0 +1,27 @@
1
+class Solution {
2
+public:
3
+ vector<vector<int>> largestLocal(vector<vector<int>>& grid) {
4
+ int n = grid.size();
5
+
6
+ for(int i = 1; i < n - 1; ++i) {
7
+ for(int j = 1; j < n - 1; ++j) {
8
+ int temp = 0;
9
10
+ for(int k = i - 1; k <= i + 1; ++k) {
11
+ for(int l = j - 1; l <= j + 1; ++l) {
12
+ temp = max(temp, grid[k][l]);
13
+ }
14
15
16
+ grid[i - 1][j - 1] = temp;
17
18
19
20
+ grid.resize(n - 2);
21
+ for (int i = 0; i < grid.size(); ++i) {
22
+ grid[i].resize(n - 2);
23
24
25
+ return grid;
26
27
+};
0 commit comments