With 1 Function Only || Constant time and space complexity
Please Upvote if you like this\n\n\n\nclass Solution {\npublic:\n    bool board[8][8];\n    void check(int i, int j, int x, int y, vector<int> &sub){        \n 
# Please Upvote if you like this\n\n\n```\nclass Solution {\npublic:\n    bool board[8][8];\n    void check(int i, int j, int x, int y, vector<int> &sub){        \n        \n        if(i < 0 || j < 0 || i >= 8 || j >= 8) return;        \n        \n        if(board[i][j] == true){\n            sub[0] = i;\n            sub[1] = j;\n            return;\n        }\n        \n        check(i + x, j + y, x, y, sub);        \n    }\n    \n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens, vector<int>& king) {\n        \n        vector<vector<int>> ans;\n        memset(board, false, sizeof(board));\n        \n        for(int i=0; i<queens.size(); i++){\n            int x = queens[i][0];\n            int y = queens[i][1];\n            board[x][y] = true;\n        }\n        \n        int dir[8][2] = {{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}};\n        \n            \n        int i = king[0];\n        int j = king[1];\n            \n        for(int v=0; v<8; v++){\n            int x = dir[v][0];\n            int y = dir[v][1];\n            vector<int> sub(2, -1);\n            check(i+x, j+y, x, y, sub);\n                \n            if(sub[0] != -1){                    \n                ans.push_back(sub);\n            }\n        }            \n        \n        return ans;\n    }\n};\n```
['C']