C++ Tracing
Trace in all directions from the king until you hit a queen or go off the board. Since the board is limited to 8 x 8, we can use a boolean matrix to lookup quee
Trace in all directions from the king until you hit a queen or go off the board. Since the board is limited to `8 x 8`, we can use a boolean matrix to lookup queen positions; we could use a hash map for a larger board.\n```\nvector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens, vector<int>& k) {\n    bool b[8][8] = {};\n    for (auto& q : queens) b[q[0]][q[1]] = true;\n    vector<vector<int>> res;\n    for (auto i = -1; i <= 1; ++i)\n        for (auto j = -1; j <= 1; ++j) {\n            if (i == 0 && j == 0) continue;\n            auto x = k[0] + i, y = k[1] + j;\n            while (min(x, y) >= 0 && max(x, y) < 8) {\n                if (b[x][y]) {\n                    res.push_back({ x, y });\n                    break;\n                }\n                x += i, y += j;\n            }\n        }\n    return res;\n}\n```
[]