C++ | checking for first queen in all 8 directions | faster than 100%
Checking for first queen in all 8 directions from the king\n\n\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& quee
[](http://)Checking for first queen in all 8 directions from the king\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& queens, vector<int>& king) {\n        int i,j;\n        j=king[1]-1;\n        i=king[0];\n        vector<vector<int>> res;\n        //row left\n        while(j>=0)\n        {\n           if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n               break;\n           }\n            j--;\n        }\n        //row right\n        j=king[1]+1;\n        while(j<8)\n        {\n             if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n                 break;\n           }\n            j++;\n        }\n        // col up\n        i=king[0]-1;\n        j=king[1];\n        while(i>=0)\n        {\n            if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n                 break;\n           }\n            i--;\n        }\n        //col down\n        i=king[0]+1;\n        while(i<8)\n        {\n            if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n                 break;\n           }\n            i++;\n        }\n        // northwest\n        i=king[0]-1;\n        j=king[1]-1;\n        while(i>=0 && j>=0)\n        {\n            if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n                 break;\n           }\n            i--;\n            j--;\n        }\n        // northeast\n        i=king[0]-1;\n        j=king[1]+1;\n        while(i>=0 && j<8)\n        {\n            if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n                 break;\n           }\n            i--;\n            j++;\n        } \n        // southwest\n        i=king[0]+1;\n        j=king[1]-1;\n        while(i<8 && j>=0)\n        {\n            if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n                 break;\n           }\n            i++;\n            j--;\n        }\n        //southeast\n        i=king[0]+1;\n        j=king[1]+1;\n        while(i<8 && j<8)\n        {\n            if(count(queens.begin(),queens.end(),vector<int> {i,j})==1)\n           {\n               res.push_back(vector<int>{i,j});\n                 break;\n           }\n            i++;\n            j++;\n        }\n        return res;\n    }\n};\n```
['C', 'C++']