Python, easy to read/understand, constant space/time
There were already many constant space/time solutions in Python already, but I felt that many of them were hard to read despite being written in python, which i
There were already many constant space/time solutions in Python already, but I felt that many of them were hard to read despite being written in python, which is why I decided to post my solution.\n\n1. Convert `queens` to a set. This way we can check if a queen exists at (x, y) in O(1) space.\n2. I wrote the 8 steps that can be taken in different directions from the position of the `king`.\n3. For each direction, start from the location of `king` and walk outwards until a `queen` is found.\n\n\n```python\nclass Solution:\n    def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n        queens = set([(x, y) for x, y in queens])\n        directions = [\n            (1, 0), (-1, 0), (0, 1), (0, -1),\n            (1, 1), (-1, -1), (1, -1), (-1, 1)\n        ]\n        check = []\n\n        for dx, dy in directions:\n            x, y = king\n            while 0 <= x < 8 and 0 <= y < 8 and (x, y) not in queens:\n                x += dx\n                y += dy\n\n            if (x, y) in queens:\n                check += (x, y),\n\n        return check\n```
[]