Easy python solution using 2 for loops
Intuition\nTo find themaximum value in every contiguous 3X3 matrix we iterate over the  each cell in the grid except the last two rows and columns. \nFor each c
# Intuition\nTo find themaximum value in every contiguous 3X3 matrix we iterate over the  each cell in the grid except the last two rows and columns. \nFor each cell we consider 3X3 submatrix centred around that cell and find the maximum value within it\n\n# Approach\n1. Iterating over grid cells:\n    - we iterate over each cell in the grid except the last two rows and columns because we need a 3X3 submatrix  centred around each cell, and those cells on the borders don\'t have enough space for submatrices.\n2. Finding maximum value in submatrix:\n    - For each cell (\'i,j\') in the grid, we extract the 3X3 submatrix cnetred around it using list slicing. \n    - Then, we find the maximum value within its submatrix using max function.\n3. Constructing resulting matrix:\n    - We store the maximum value found for each submatrix in the resulting matrix \'res\'.\n4. Returning the result\n\n# Complexity\n- Time complexity: *******O(n^2)*******\n\n\n- Space complexity: *O(n^2)*\n\n# Code\n```\nclass Solution:\n    def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n        #initialize an empty list to store the resulting matrix\n        res = []\n\n        #iterate over each row of the grid, leaving last two rows\n        for i in range(len(grid)-2):\n\n            #append an empty list to res for the current row\n            res.append([])\n\n            #iterate over each column of the grid, leaaving last two columns \n            for j in range(len(grid[0])-2):\n\n                #extract the curretn 3*3 submatrix and find the maximum value within it\n                max_val = max(\n                    grid[i][j:j+3]+   #top row of submatrix\n                    grid[i+1][j:j+3]+ #middle row of the submatrix\n                    grid[i+2][j:j+3]  #bottom row of the submatrix\n                )\n\n                #append the max_val to the current row of the res matrix\n                res[i].append(max_val)\n                \n        #return resulting matrix\n        return res\n```
['Python3']