Better than 100%(Checking in all 8 directions)
IntuitionApproachComplexity

Time complexity:
O(8*8)


Space complexity:


O(1)

Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
O(8*8)

- Space complexity:
- O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens,
                                            vector<int>& king) {
        vector<vector<int>> board(8, vector<int>(8, -2));

        board[king[0]][king[1]] = 1;
        for (auto q : queens) {
            board[q[0]][q[1]] = 0;
        }

        int i = king[0], j = king[1];
        while (i >= 0) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            i--;
        }

        i = king[0], j = king[1];
        while (i < 8) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            i++;
        }

        i = king[0], j = king[1];
        while (j < 8) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            j++;
        }

        i = king[0], j = king[1];
        while (j >= 0) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            j--;
        }

        i = king[0], j = king[1];
        while (i < 8 and j < 8) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            j++, i++;
        }

        i = king[0], j = king[1];
        while (j >= 0 and i >= 0) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            j--, i--;
        }

        i = king[0], j = king[1];
        while (j >= 0 and i < 8) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            j--, i++;
        }

        i = king[0], j = king[1];
        while (j < 8 and i >= 0) {
            if (board[i][j] == 0) {
                board[i][j] = -1;
                break;
            }
            j++, i--;
        }
        vector<vector<int>> ans;
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                if (board[i][j] == -1)
                    ans.push_back({i, j});
            }
        }
        return ans;
    }
};
```
['C++']