☑✅ JAVA || Easy to Understand || Simple Approach
The approach is to create an array of 8 * 8 and mark the queens as 1.\nChecking all 8 directions around the King.\nFinding the nearest queen in each direction a
The approach is to create an array of 8 * 8 and mark the queens as 1.\nChecking all 8 directions around the King.\nFinding the nearest queen in each direction and add the coordinate of that queen in answer.\n\n```\nclass Solution {\n    public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n        int[][] chess = new int[8][8];\n        \n        for(int[] queen : queens){\n            int x = queen[0];\n            int y = queen[1];\n            chess[x][y] = 1;\n        }\n        \n        List<List<Integer>> ans = new ArrayList<>();\n        int x = king[0];    // x coordinate of king\n        int y = king[1];    // y coordinate of king\n        \n        // checking column left to king\n        for(int j = y - 1; j >= 0; j--){\n            if(chess[x][j] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(x);\n                list.add(j);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        // checking column right to king\n        for(int j = y + 1; j < 8; j++){\n            if(chess[x][j] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(x);\n                list.add(j);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        // checking row above the king\n        for(int i = x - 1; i >= 0; i--){\n            if(chess[i][y] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(i);\n                list.add(y);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        // checking row below the king\n        for(int i = x + 1; i < 8; i++){\n            if(chess[i][y] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(i);\n                list.add(y);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        // checking left diagonal above the king\n        for(int i = x - 1, j = y - 1; i >= 0 && j >= 0; i--, j--){\n            if(chess[i][j] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(i);\n                list.add(j);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        // checking left diagonal below the king\n        for(int i = x + 1, j = y + 1; i < 8 && j < 8; i++, j++){\n            if(chess[i][j] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(i);\n                list.add(j);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        // checking right diagonal above the king\n        for(int i = x - 1, j = y + 1; i >= 0 && j < 8; i--, j++){\n            if(chess[i][j] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(i);\n                list.add(j);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        // checking right diagonal below the king\n        for(int i = x + 1, j = y - 1; i < 8 && j >= 0; i++, j--){\n            if(chess[i][j] == 1){\n                List<Integer> list = new ArrayList<>();\n                list.add(i);\n                list.add(j);\n                ans.add(new ArrayList<>(list));\n                break;\n            }\n        }\n        \n        return ans;\n    }\n}\n```
['Java']