Simpler || Faster || Fully Explained || Beats 100 % C#
Intuition\n Describe your first thoughts on how to solve this problem. \nSimply use for loops to iterate over the matrix, with limit as n-2 for outer loops and 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimply use for loops to iterate over the matrix, with limit as n-2 for outer loops and i+3, j+3 for inner loops\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nInput: grid = [[9,9,8,1],\n               [5,6,2,6],\n               [8,2,6,4],\n               [6,2,2,2]]\n\n(i) i) i = 0, j = 0;\n res[0] =new int[n-2] = new int[2] =  [,]\n\n  (aa) ii =0, jj = 0 , ii & jj < 3\n     res[0][0] = Math.Max(0,9) = 9\n  (ab) ii = 0, jj = 1 , ii & jj <3\n     res[0][0] = Math.Max(9,9) = 9\n  (ac) ii = 0, jj = 2 , ii & jj <3\n     res[0][0] = Math.Max(9,8) = 9\n \n  (ba) ii =1, jj = 0 , ii & jj < 3\n     res[0][0] = Math.Max(9,5) = 9\n  (bb) ii = 1, jj = 1 , ii & jj <3\n     res[0][0] = Math.Max(9,6) = 9\n  (bc) ii = 1, jj = 2 , ii & jj <3\n     res[0][0] = Math.Max(9,2) = 9\n\n  (ca) ii =2, jj = 0 , ii & jj < 3\n     res[0][0] = Math.Max(9,8) = 9\n  (cb) ii = 2, jj = 1 , ii & jj <3\n     res[0][0] = Math.Max(9,2) = 9\n  (cc) ii = 2, jj = 2 , ii & jj <3\n     res[0][0] = Math.Max(9,6) = 9 \n\nFinally res[0][0] = 9\n\nNext\n (i) ii) i = 0, j = 1\n\n    (aa) ii = 0, jj = 1 , ii <3 & jj < 4\n        res[0][1] = Math.Max(0,9) = 9\n    (ab) ii = 0, jj = 2 , ii<3 & jj <4\n       res[0][1] = Math.Max(9,8) = 9\n    (ac) ii = 0, jj = 3 , ii<3 & jj <4\n      res[0][1] = Math.Max(9,1) = 9\n \n    (ba) ii = 1, jj = 1 , ii <3 & jj < 4\n        res[0][1] = Math.Max(9,6) = 9\n    (bb) ii = 1, jj = 2 , ii<3 & jj <4\n       res[0][1] = Math.Max(9,2) = 9\n    (bc) ii = 1, jj = 3 , ii<3 & jj <4\n      res[0][1] = Math.Max(9,6) = 9\n   \n    (ca) ii = 2, jj = 1 , ii <3 & jj < 4\n        res[0][1] = Math.Max(9,2) = 9\n    (cb) ii = 2, jj = 2 , ii<3 & jj <4\n       res[0][1] = Math.Max(9,6) = 9\n    (cc) ii = 2, jj = 3 , ii<3 & jj <4\n      res[0][1] = Math.Max(9,4) = 9\n  \n\nFinally res[0][1] = 9\n\nsimilary for other values of res array will also be calculated.\n\n \n\nOutput: [[9,9],[8,6]]\n\n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```C# []\npublic class Solution {\n    public int[][] LargestLocal(int[][] grid) {\n        int n = grid.Length;\n        var res = new int[n-2][];\n        for(int i = 0; i<n-2;i++){\n            res[i] = new int[n-2];\n            for(int j = 0; j<n-2; j++){\n                for(int ii = i; ii<i+3;ii++){\n                    for(int jj = j; jj<j+3;jj++){\n                        res[i][j] = Math.Max(res[i][j],grid[ii][jj]);\n                    }\n                }\n            }\n        }\n        return res;\n    }\n}\n```\n```Java []\npublic class Solution {\n    public int[][] largestLocal(int[][] grid) {\n        int n = grid.length;\n        int[][] res = new int[n - 2][];\n\n        for (int i = 0; i < n - 2; i++) {\n            res[i] = new int[n - 2];\n            for (int j = 0; j < n - 2; j++) {\n                for (int ii = i; ii < i + 3; ii++) {\n                    for (int jj = j; jj < j + 3; jj++) {\n                        res[i][j] = Math.max(res[i][j], grid[ii][jj]);\n                    }\n                }\n            }\n        }\n        return res;\n    }\n}\n```\n```Python []\nclass Solution(object):\n    def largestLocal(self, grid):\n        """\n        :type grid: List[List[int]]\n        :rtype: List[List[int]]\n        """\n        n = len(grid)\n        res = [[0] * (n - 2) for _ in range(n - 2)]\n\n        for i in range(n - 2):\n            for j in range(n - 2):\n                max_val = float(\'-inf\')\n                for ii in range(i, i + 3):\n                    for jj in range(j, j + 3):\n                        max_val = max(max_val, grid[ii][jj])\n                res[i][j] = max_val\n\n        return res\n\n```
['Array', 'Matrix', 'Python', 'Java', 'C#']