Python Elegant & Short | 100% faster
\n\n\n\nclass Solution:\n\t"""\n\tTime:   O(n^2)\n\tMemory: O(1)\n\t"""\n\n\tdef largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\t\tn = len(grid
![image](https://assets.leetcode.com/users/images/0a9a0d13-e9cb-430f-8777-e73df4685f7a_1660554242.9688396.png)\n\n\n```\nclass Solution:\n\t"""\n\tTime:   O(n^2)\n\tMemory: O(1)\n\t"""\n\n\tdef largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n\t\tn = len(grid)\n\t\treturn [[self.local_max(grid, r, c, 1) for c in range(1, n - 1)] for r in range(1, n - 1)]\n\n\t@staticmethod\n\tdef local_max(grid: List[List[int]], row: int, col: int, radius: int) -> int:\n\t\treturn max(\n\t\t\tgrid[r][c]\n\t\t\tfor r in range(row - radius, row + radius + 1)\n\t\t\tfor c in range(col - radius, col + radius + 1)\n\t\t)\n```\n\nIf you like this solution remember to **upvote it** to let me know.\n\n
['Python', 'Python3']