Very Intuitive || Easy 2 For loop Solution ⭐✨
Problem Description\n\nGiven a 2D grid of integers, find the largest element in each 3x3 local region within the grid.\n\n## Intuition\nThe problem seems to be 
# Problem Description\n\nGiven a 2D grid of integers, find the largest element in each 3x3 local region within the grid.\n\n## Intuition\nThe problem seems to be asking for finding the largest element in each 3x3 local region within the given grid. We can iterate over each cell in the grid and find the maximum value within its 3x3 neighborhood.\n\n## Approach\n1. Iterate over each cell in the grid, excluding the boundary cells (i.e., the outermost layer of cells).\n2. For each cell, find the maximum value among the cell itself and its eight neighboring cells.\n3. Store the maximum value in the corresponding position in the result grid.\n\n## Complexity\n- Time complexity: O(n^2), where n is the size of the grid. We iterate over each cell in the grid once.\n- Space complexity: O(n^2) for storing the result grid, where n is the size of the input grid.\n\n# Code\n```cpp\nclass Solution{\npublic: \n\n    vector<vector<int>> largestLocal(vector<vector<int>>& grid) {\n        \n        int n = grid.size();\n        vector<vector<int>> res(n - 2, vector<int>(n - 2));\n\n        for(int i = 1; i <= n - 2; i++) {\n            for(int j = 1; j <= n - 2; j++) {\n                int maxi = 0;\n                maxi = max({maxi, grid[i-1][j-1], grid[i-1][j], grid[i-1][j+1], grid[i][j-1], grid[i][j], grid[i][j+1], grid[i+1][j-1], grid[i+1][j], grid[i+1][j+1]});\n                \n                res[i-1][j-1] = maxi;\n            }\n        }\n        return res;\n    }\n};\n
['Array', 'Matrix', 'C++']