C++ solution greedy
\n// Please, upvote if you like it. Thanks :-)\nvector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n\tint n = colsum.size();\n\t
```\n// Please, upvote if you like it. Thanks :-)\nvector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n\tint n = colsum.size();\n\tint sum = accumulate(begin(colsum), end(colsum), 0);\n\tif (upper + lower != sum)\n\t\treturn {};\n\tvector<vector<int>> res(2, vector<int>(n));\n\tfor (int i = 0; i < n; i++) {\n\t\tif (colsum[i] == 2) {\n\t\t\tres[0][i] = res[1][i] = 1;\n\t\t\tupper--, lower--;\n\t\t}\n\t\telse if (colsum[i] == 1) {\n\t\t\tif (upper > lower)\n\t\t\t\tres[0][i] = 1, upper--;\n\t\t\telse\n\t\t\t\tres[1][i] = 1, lower--;\n\t\t}\n\t}\n\tif (lower == 0 && upper == 0)\n\t\treturn res;\n\treturn {};\n}\n```
['Array', 'Greedy', 'C', 'Matrix', 'C++']