Python | Easy
see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n    def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n        n = len(gr
[see the Successfully Accepted Submission](https://leetcode.com/problems/largest-local-values-in-a-matrix/submissions/1255807734/?source=submission-ac)\n\n# Code\n```\nclass Solution:\n    def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n        n = len(grid)\n        result = []\n\n        for i in range(n - 2):\n            row = []\n            for j in range(n - 2):\n                submatrix = [grid[x][j:j+3] for x in range(i, i+3)]\n                max_val = max(max(sub) for sub in submatrix)\n                row.append(max_val)\n            result.append(row)\n\n        return result\n        \n```\n![image](https://assets.leetcode.com/users/images/b1e4af48-4da1-486c-bc97-b11ae02febd0_1696186577.992237.jpeg)
['Python3']