Four Loops
It\'s easy to overthink this problem. \n\nFor each output cell, we need to process 9 input cells, total 9 * (n - 2) * (n - 2) operations.\n\nC++\ncpp\nvector<ve
It\'s easy to overthink this problem. \n\nFor each output cell, we need to process 9 input cells, total `9 * (n - 2) * (n - 2)` operations.\n\n**C++**\n```cpp\nvector<vector<int>> largestLocal(vector<vector<int>>& g) {\n    int n = g.size();\n    vector<vector<int>> res(n - 2, vector<int>(n - 2));\n    for (int i = 0; i < n - 2; ++i)\n        for (int j = 0; j < n - 2; ++j)\n            for (int ii = i; ii < i + 3; ++ii)\n                for (int jj = j; jj < j + 3; ++jj)\n                    res[i][j] = max(res[i][j], g[ii][jj]);\n    return res;\n}\n```
[]