leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

2373.cpp (550B)


      1 class Solution {
      2   public:
      3     vector<vector<int>> largestLocal(const vector<vector<int>> &grid) const {
      4         const int n = size(grid);
      5         vector<vector<int>> res(n - 2, vector(n - 2, 0));
      6 
      7         for (int i = 0; i < n - 2; i++) {
      8             for (int j = 0; j < n - 2; j++) {
      9                 for (int k = i; k <= i + 2; k++) {
     10                     for (int l = j; l <= j + 2; l++) {
     11                         res[i][j] = max(res[i][j], grid[k][l]);
     12                     }
     13                 }
     14             }
     15         }
     16 
     17         return res;
     18     }
     19 };