leetcode

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

2428.cpp (465B)


      1 class Solution {
      2   public:
      3     int maxSum(const vector<vector<int>> &grid) {
      4         int m = grid.size(), n = grid[0].size(), res = 0;
      5         for (int i = 0; i < m - 2; ++i) {
      6             for (int j = 0; j < n - 2; ++j)
      7                 res = max(res, grid[i + 0][j] + grid[i + 0][j + 1] + grid[i + 0][j + 2] + grid[i + 1][j + 1] +
      8                                    grid[i + 2][j] + grid[i + 2][j + 1] + grid[i + 2][j + 2]);
      9         }
     10         return res;
     11     }
     12 };