Beats 100% | ✅
\n_____\n\n# Up Vote if Helps\n\n_____\n\n\n# Code\n\nclass Solution {\n    List<List<Integer>> ans=new ArrayList<>();\n    int[][] board;\n    public List<List
![Screenshot (637).png](https://assets.leetcode.com/users/images/ab412f29-49ec-4f25-beb1-26cbaca4027b_1708513346.8983362.png)\n______________________________________\n\n# **Up Vote if Helps**![image.png](https://assets.leetcode.com/users/images/23d8443e-ac59-49d5-99f0-9273a2147be2_1687635435.0337658.png)\n\n______________________________________\n\n\n# Code\n```\nclass Solution {\n    List<List<Integer>> ans=new ArrayList<>();\n    int[][] board;\n    public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n        board=new int[8][8];\n        for(int i=0; i<queens.length; i++){\n            int row=queens[i][0];\n            int col=queens[i][1];\n            board[row][col]=1;\n        }\n        top(king[0],king[1]);\n        bottom(king[0],king[1]);\n        left(king[0],king[1]);\n        right(king[0],king[1]);\n        topleft(king[0],king[1]);\n        topRight(king[0],king[1]);\n        bottomLeft(king[0],king[1]);\n        bootomRight(king[0],king[1]);\n        return ans;\n    }\n    public void top(int row, int col){\n        for(int i=row ; i>=0 ; i--){\n            if(board[i][col]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(i);\n               temp.add(col);\n               ans.add(temp);\n               return;\n            }\n        }\n    }\n    public void bottom(int row, int col){\n        for(int i=row; i<8; i++){\n            if(board[i][col]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(i);\n               temp.add(col);\n               ans.add(temp);\n               return;\n            }           \n        }\n    }\n    public void left(int row, int col){\n        for(int j=col; j>=0; j--){\n            if(board[row][j]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(row);\n               temp.add(j);\n               ans.add(temp);\n               return;\n            }               \n        }\n    }\n    public void right(int row, int col){\n        for(int j=col ; j<8 ; j++){\n            if(board[row][j]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(row);\n               temp.add(j);\n               ans.add(temp);\n               return;\n            }\n        }\n    }\n    public void topleft(int row, int col){\n        for(int i=row, j=col; i>=0 && j>=0 ; i--,j--){\n            if(board[i][j]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(i);\n               temp.add(j);\n               ans.add(temp);\n               return;\n            }      \n        }\n    }\n    public void topRight(int row, int col){\n        for(int i=row, j=col; i>=0 && j<8 ; i--,j++){   \n            if(board[i][j]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(i);\n               temp.add(j);\n               ans.add(temp);\n               return;\n            }           \n        }\n    }\n    public void bottomLeft(int row, int col){\n        for(int i=row,j=col; i<8 && j>=0 ; i++, j--){\n             if(board[i][j]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(i);\n               temp.add(j);\n               ans.add(temp);\n               return;\n            }           \n        }\n    }\n    public void bootomRight(int row, int col){\n        for(int i=row, j=col; i<8 && j<8 ; i++,j++){\n             if(board[i][j]==1){\n               List<Integer> temp=new ArrayList<>();\n               temp.add(i);\n               temp.add(j);\n               ans.add(temp);\n               return;\n            }\n        }\n    }  \n}\n```\n______________________________________\n\n# **Up Vote if Helps**![image.png](https://assets.leetcode.com/users/images/23d8443e-ac59-49d5-99f0-9273a2147be2_1687635435.0337658.png)\n\n______________________________________
['Java']