Simple Python 100% speed and 100% memory
\n\n\n\ndef queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n        result = []\n        seen = [[False for _ in range(
![image](https://assets.leetcode.com/users/palaivishal/image_1590565899.png)\n\n\n```\ndef queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n        result = []\n        seen = [[False for _ in range(8)] for _ in range(8)] # create a 8 X 8 board \n        \n        for queen in queens: \n            seen[queen[0]][queen[1]] = True  # set true for the queens in the board with x and y co-ords\n        \n        directions = [-1, 0, 1] # 1 goes forward, -1 backwards and 0 not goes anywhere\n        \n        for dx in directions:\n            for dy in directions: # these 2 loops help traverse all 9 sides around the king\n                if dx == 0 and dy == 0:\n                    continue\n                x = king[0]\n                y = king[1]\n                \n                while x + dx >= 0 and x + dx < 8 and y + dy >= 0 and y + dy < 8:\n                    x = x + dx \n                    y = y + dy                     \n                    if seen[x][y]:\n                        result.append([x,y])\n                        break # this break is important and handles the case of a queen behind another queen       \n        return result\n```
['Dynamic Programming', 'Python', 'Python3']