C++ | Greedy
\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) \n    {\n        int n=colsum.size();\n       
```\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) \n    {\n        int n=colsum.size();\n        vector<vector<int>>res(2,vector<int>(n,0));\n        for(int i=0;i<n;i++)\n        {\n            if(colsum[i]==2)\n            {\n                upper--;\n                lower--;\n                res[0][i]=1;\n                res[1][i]=1;\n            }\n        }\n        if(upper<0 || lower<0)\n            return {};\n        for(int i=0;i<n;i++)\n        {\n            if(colsum[i]==1)\n            {\n                if(upper)\n                {\n                    upper--;\n                    res[0][i]=1;\n                }\n                else\n                {\n                    lower--;\n                    res[1][i]=1;\n                }\n            }\n        }\n        if(upper!=0 || lower!=0)\n            return {};\n        return res;\n    }\n};\n```
[]