c++ | simple | easy to understand
\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& arr, vector<int>& king) {\n        set<pair<int,int>>st;\n\t for(i
```\nclass Solution {\npublic:\n    vector<vector<int>> queensAttacktheKing(vector<vector<int>>& arr, vector<int>& king) {\n        set<pair<int,int>>st;\n\t for(int i=0;i<arr.size();i++)\n\t {\n\t \tst.insert(make_pair(arr[i][0],arr[i][1]));\n\t }\n\t vector<vector<int>>ans;\n\t \n     int row=king[0];   //row\n\t int col=king[1];   //col\n\t \n\t //checking the first part...1\n     //row will be constant\n     while(col<8)\n     {\n     \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    col++;\n\t }\n\t \n\t //checking the second part...2\n\t //row will be constant\n\t row=king[0];   //row\n\t col=king[1];   //col\n\t \n\t while(col>=0)\n\t {\n\t \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    col--;\n\t }\n\t \n\t //checking the third part...3\n\t //col will be constant\n\t row=king[0];   //row\n\t col=king[1];   //col\n\t \n\t while(row>=0)\n\t {\n\t \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    row--;\n\t }\n\t \n\t \n\t //checking the fourth part...4\n\t //col will be constant\n\t row=king[0];   //row\n\t col=king[1];   //col\n\t \n\t while(row<8)\n\t {\n\t \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    row++;\n\t }\n\t \n\t //checking the fifth part...5\n\t row=king[0];   //row\n\t col=king[1];   //col\n\t \n\t while(row>=0 and col<8)\n\t {\n\t \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    row--;\n\t    col++;\n\t }\n\t \n\t //checking the sixth part...6\n\t \n\t row=king[0];   //row\n\t col=king[1];   //col\n\t \n\t while(row<8 and col>=0)\n\t {\n\t \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    row++;\n\t    col--;\n\t }\n\t \n\t //checking the third part...7\n\n\t row=king[0];   //row\n\t col=king[1];   //col\n\t \n\t while(row>=0 and col>=0)\n\t {\n\t \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    row--;\n\t    col--;\n\t }\n\t \n\t //checking the third part...8\n\t \n\t row=king[0];   //row\n\t col=king[1];   //col\n\t \n\t while(row<8 and col<8)\n\t {\n\t \tif(st.find(make_pair(row,col))!=st.end())\n     \t{\n     \t   ans.push_back({row,col});  //we found a queen attacking the king   \t\n     \t   break;\n\t    }\n\t    row++;\n\t    col++;\n\t }\n     return ans;\n    }\n};\n```
['C', 'C++']