c++ || greedy approach
\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& col) {\n        int m = col.size();\n        vector<ve
```\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& col) {\n        int m = col.size();\n        vector<vector<int>> temp(2,vector<int>(m));\n        vector<int> row = {upper,lower};\n        int rowSum = accumulate(row.begin(), row.end(), 0);\n        int colSum = accumulate(col.begin(), col.end(), 0);\n        if(rowSum != colSum) return vector<vector<int>>();\n        \n        for(int j=0;j<m;j++){\n            if(col[j] == 2){\n                temp[0][j]=1; row[0]--;\n                temp[1][j]=1; row[1]--;\n            }\n            else if(col[j]==1){\n                if(row[0] > row[1]){\n                    temp[0][j]=1; row[0]--;\n                }\n                else{\n                    temp[1][j]=1; row[1]--;\n                }\n            }\n        }\n        if(row[0]!=0 || row[1]!=0) return {};\n        return temp;\n    }\n};\n```
[]