Greedy C++
\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int n = colsum.size();\n        vector<vector<int>> ans(2, vec
```\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int n = colsum.size();\n        vector<vector<int>> ans(2, vector<int> (n, 0));\n        \n        int i = 0, j = 0;\n        while(j < n){\n            if(colsum[j] == 2){\n                ans[0][j] = 1;\n                ans[1][j] = 1;\n                \n                upper--;\n                lower--;\n            }\n            else if(colsum[j] == 1){\n                if(upper > lower){\n                    ans[0][j] = 1;\n                    upper--;\n                }\n                else{\n                    ans[1][j] = 1;\n                    lower--;\n                }\n            }\n            j++;\n        }\n        \n        return (upper == 0 && lower == 0) ? ans : vector<vector<int>> ();\n    } \n```
['Greedy', 'C']