C++ | Checking in all 8 directions
\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens, vector<int>& king) {\n        vector<vector<int>>ans;\n   
```\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens, vector<int>& king) {\n        vector<vector<int>>ans;\n        vector<vector<int>>seen(8,vector<int>(8,0));\n        for(auto queen:queens){\n            seen[queen[0]][queen[1]]=1;\n        }\n        for(int dx=-1;dx<=1;dx++){\n            for(int dy=-1;dy<=1;dy++){\n                if(dx==0 && dy==0){\n                    continue;\n                }\n                int x=king[0];\n                int y=king[1];\n                \n                while(x+dx>=0 && y+dy>=0 && x+dx<8 && y+dy<8){\n                    x+=dx;\n                    y+=dy;\n                    if(seen[x][y]){\n                        ans.push_back({x,y});\n                        break; // ones we got a queen in our current path we will stop\n                    }\n                }\n            }\n        }\n        return ans;\n    }\n};\n```\n#### **If you understood the solution please upvote :)**
['C', 'C++']