leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
2373.cpp (550B)
0 class Solution { 1 public: 2 vector<vector<int>> largestLocal(const vector<vector<int>> &grid) const { 3 const int n = size(grid); 4 vector<vector<int>> res(n - 2, vector(n - 2, 0)); 5 6 for (int i = 0; i < n - 2; i++) { 7 for (int j = 0; j < n - 2; j++) { 8 for (int k = i; k <= i + 2; k++) { 9 for (int l = j; l <= j + 2; l++) { 10 res[i][j] = max(res[i][j], grid[k][l]); 11 } 12 } 13 } 14 } 15 16 return res; 17 } 18 };