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