✅C++ | ✅Simple and efficient solution | ✅TC:O((n-2)^2)
Please upvote if it helps :)\n\nclass Solution \n{\npublic:\n    vector<vector<int>> largestLocal(vector<vector<int>>& grid) \n    {\n        int n=grid.size();
**Please upvote if it helps :)**\n```\nclass Solution \n{\npublic:\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        //find max of 3x3 grid centred around row (i+1) and column (j+1)\n\t\t//for eg:1 starting from (1,1) so (1,1),(1,2),(2,1),(2,2) will be the centre of 3x3 grid-1,2,3,4 respectively\n        for(int i=1; i<=n-2; i++)\n        {\n            for(int j=1; j<=n-2; j++)\n            {\n                int maxi=0;\n                maxi = max({maxi, grid[i-1][j-1], grid[i-1][j], grid[i-1][j+1]});\n                maxi = max({maxi, grid[i][j-1], grid[i][j], grid[i][j+1]});\n                maxi = max({maxi, 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```
['C', 'Matrix', 'C++']