Easy C++ Greedy solution || commented
\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        \n        //first fill the cols who
```\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        \n        //first fill the cols whose colsum[i]==2 \n        \n        vector<vector<int>> empty;\n        int len=colsum.size();\n        vector<vector<int>> res(2,vector<int>(len,0));\n        \n        //the count of cols whose colsum[i]==1\n        int ones=0;\n        for(int i=0;i<len;i++)\n        {\n            if(colsum[i]==1)\n                ones++;\n            else if(colsum[i]==2)\n            {\n                if(upper==0 || lower==0)\n                    return empty;\n                res[0][i]=res[1][i]=1;\n                upper--;\n                lower--;\n            }\n        }\n\t\t// we cant fill the cols whose colsum is 1\n        if(ones!=(lower+upper))\n            return empty;\n        \n        for(int i=0;i<len;i++)\n        {\n            if(colsum[i]==1)\n            {\n                if(upper)\n                {   \n\t\t\t\t    //fill the first row\n                    res[0][i]=1;\n                    upper--;\n                }\n                else{\n\t\t\t\t//fill the second row\n                    res[1][i]=1;\n                    lower--;\n                }\n            }\n        }\n        return res;\n    }\n};\n```
['Greedy', 'C']