Python3     ||     5 lines, iteration     ||    T/S: 92% / 71%
Pretty much explains itself.\n\nclass Solution:\n    def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\n        n = len(grid)-2\n        ans =
Pretty much explains itself.\n```\nclass Solution:\n    def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\n        n = len(grid)-2\n        ans = [[0]*n for _ in range(n)]\n\n        for i,j in product(range(n),range(n)):\n            ans[i][j] = max(grid[I][J] for I,J in\n                            product(range(i,i+3),range(j,j+3)))\n\n        return  ans\n```\n\n[https://leetcode.com/problems/largest-local-values-in-a-matrix/submissions/1255744400/](https://leetcode.com/problems/largest-local-values-in-a-matrix/submissions/1255744400/)\n\nI could be wrong, but I think that time complexity is *O*(*N* ^2) and space complexity is *O*(*N* ^2), in which *M* ~ `len(grid)` and *N* ~ `len(grid[0])`.
['Python', 'Python3']