✅✅Beats 100% || 🚀🚀 Easiest Solution || 😊😊Be Motivated😊😊 ||
Intuition\n\n # UPVOTE IF THIS HELPS YOU\n\n# Code\n\n#include <vector>\n\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<
# Intuition\n![Screenshot 2024-02-08 225627.png](https://assets.leetcode.com/users/images/522488e3-d51e-4bde-805e-c434d5f7079c_1707413201.79005.png)\n # UPVOTE IF THIS HELPS YOU\n\n# Code\n```\n#include <vector>\n\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& q, vector<int>& k) {\n        vector<vector<int>> v(8,vector<int>(8, 0));\n        int n = q.size();\n        for (int i = 0; i < n; i++) {\n            v[q[i][0]][q[i][1]] = 1;\n        }\n        vector<vector<int>> ans;\n        int x = k[0];\n        int y = k[1]; \n        for (int i = -1; i <= 1; i++) {\n            for (int j = -1; j <= 1; j++) {\n                if (i == 0 && j == 0) continue; \n                int row = x + i;\n                int col = y + j; \n                while (row >= 0 && row < 8 && col >= 0 && col < 8) {\n                    if (v[row][col] == 1) {\n                        ans.push_back(vector<int>{row, col});\n                        break;\n                    } \n                    row += i;\n                    col += j;\n                }\n            }\n        } \n        return ans;\n    }\n};\n\n```
['Matrix', 'Simulation', 'C++']