100% faster | Moving each direction separately | Python
\n\nclass Solution(object):\n    def queensAttacktheKing(self, queens, king):\n        ans = []\n        for i in range(king[0] - 1, -1, -1):\n            if [i
![image](https://assets.leetcode.com/users/images/7bdf2c5b-7c89-4215-b9e1-df7dcc196df2_1669825212.6354399.png)\n```\nclass Solution(object):\n    def queensAttacktheKing(self, queens, king):\n        ans = []\n        for i in range(king[0] - 1, -1, -1):\n            if [i, king[1]] in queens:\n                ans.append([i, king[1]])\n                break\n        c1, c2 = king[0] - 1, king[1] - 1\n        while c1 >= 0 and c2 >= 0:\n            if [c1, c2] in queens:\n                ans.append([c1, c2])\n                break\n            c1 -= 1\n            c2 -= 1\n        for i in range(king[1] - 1, -1, -1):\n            if [king[0], i] in queens:\n                ans.append([king[0], i])\n                break\n        for i in range(king[1] + 1, 8):\n            if [king[0], i] in queens:\n                ans.append([king[0], i])\n                break\n        c1, c2 = king[0] - 1, king[1] + 1\n        while -1 < c1 and 8 > c2:\n            if [c1, c2] in queens:\n                ans.append([c1, c2])\n                break\n            c1, c2 = c1 - 1, c2 + 1\n        c1, c2 = king[0] + 1, king[1] - 1\n        while 8 > c1 and -1 < c2:\n            if [c1, c2] in queens:\n                ans.append([c1, c2])\n                break\n            c1 += 1\n            c2 -= 1\n        for i in range(king[0], 8):\n            if [i, king[1]] in queens:\n                ans.append([i, king[1]])\n                break\n        c1, c2 = king[0] + 1, king[1] + 1\n        while 8 > c1 and 8 > c2:\n            if [c1, c2] in queens:\n                ans.append([c1, c2])\n                break\n            c1, c2 = c1 + 1, c2 + 1\n        return ans\n```\n
['Python', 'Python3']