Java: a BFS on the king in 8 different directions (keep queens in a set) O(N)
Keep track of all queen positons in a set so then you will know if your curr position is a queen. \nA BFS on the king in 8 different directions when you meet a 
Keep track of all queen positons in a set so then you will know if your curr position is a queen. \nA BFS on the king in 8 different directions when you meet a queen, stop there. \n\n```\nclass Solution {\n    private final int[][] moves = new int[][] {{0, 1}, {1, 0}, {1, 1}, {-1, 0}, {0,-1}, {-1,-1}, {-1, 1}, {1, -1}};\n    public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n        List<List<Integer>> res = new ArrayList<>();\n        Set<Integer> queensP = new HashSet<>();\n        for (int[] queen : queens) {\n            queensP.add(queen[0]*9+queen[1]);\n        }\n        Deque<int[]> queue = new ArrayDeque<>();\n        for (int[] move : moves) {\n            queue.offer(new int[] {king[0], king[1], move[0], move[1]});\n        }\n        \n        while (!queue.isEmpty()) {\n            int[] curr = queue.poll();\n            int x = curr[0];\n            int y = curr[1];\n            int move_x = curr[2];\n            int move_y = curr[3];\n            if (x < 0 || x > 8 || y < 0 || y >= 8) continue;\n            if (queensP.contains(x*9+y)) {\n                res.add(new ArrayList<>(Arrays.asList(x, y)));\n                continue;\n            }            \n            \n            queue.offer(new int[] {x+move_x, y+move_y, move_x, move_y});\n        }\n        \n        return res;\n    }\n}\n```
[]