Easy Python Code | Long But Easy Approach ✔
Python3 Solution\n\n# Code\n\nclass Solution:\n    def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n        l = []\n
Python3 Solution\n\n# Code\n```\nclass Solution:\n    def queensAttacktheKing(self, queens: List[List[int]], king: List[int]) -> List[List[int]]:\n        l = []\n        # to traverse in straight left of king\'s position\n        for i in range(king[1], -1, -1):\n            if [king[0], i] in queens:\n                l.append([king[0], i])\n                break\n        # to traverse in straight right of king\'s position\n        for i in range(king[1], 8, 1):\n            if [king[0], i] in queens:\n                l.append([king[0], i])\n                break\n        # to traverse staright above king\'s position\n        for i in range(king[0], -1, -1):\n            if [i, king[1]] in queens:\n                l.append([i, king[1]])\n                break\n        # to traverse straight down king\'s position\n        for i in range(king[0], 8, 1):\n            if [i, king[1]] in queens:\n                l.append([i, king[1]])\n                break\n\n        # to traverse diagonally right down from king\'s position\n        for i in range(1, 8):\n            if [king[0] + i, king[1] + i] in queens:\n                l.append([king[0] + i, king[1] + i])\n                break\n            if king[0] + i > 7 or king[1] + i > 7:\n                break\n        # to traverse diagonally left up from king\'s position\n        for i in range(1, 8):\n            if [king[0] - i, king[1] - i] in queens:\n                l.append([king[0] - i, king[1] - i])\n                break\n            if king[0] - i < 0 or king[1] - i < 0:\n                break\n        # to traverse diagonally right up from king\'s position\n        for i in range(1, 8):\n            if [king[0] - i, king[1] + i] in queens:\n                l.append([king[0] - i, king[1] + i])\n                break\n            if king[0] - i < 0 or king[1] + i > 7:\n                break\n        # to traverse diagonally left down from king\'s position\n        for i in range(1, 8):\n            if [king[0] + i, king[1] - i] in queens:\n                l.append([king[0] + i, king[1] - i])\n                break\n            if king[0] + i > 7 or king[1] - i < 0:\n                break\n        return l\n\n\n```
['Python3']