Single pass C++ solution
\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int n = colsum.size();\n        \n 
```\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int n = colsum.size();\n        \n        // create 2 vectors - one filled with zeros and another empty\n        vector<vector<int>> result (2, vector<int> (n,0) );\n        vector<vector<int>> empty;\n        \n\t\t// if upper or lower cannot be greater than colsum.size(), n\n        if(upper > n || lower > n) {\n            return empty;\n        } \n        \n\t\t// check the colsum array while also constructing the new matrix\n        for(int i = 0; i < n; i++) {\n            if(colsum[i] == 2) {\n\t\t\t    // both are 1 if colsum is 2\n                result[0][i] = 1;\n                result[1][i] = 1;\n                upper--;\n                lower--;\n            }\n            else if(colsum[i] == 1) {\n                if(upper>lower) {\n\t\t\t\t    // make upper row 1 only if upper is greater than lower\n\t\t\t\t\t// this ensures that if a 2 comes later we still have sufficient upper counts left to insert 1 in upper row  \n                    result[0][i] = 1;\n                    upper--;\n                }\n                else {\n                    result[1][i] = 1;\n                    lower--;\n                }\n            }\n        }\n        \n        // upper and lower will be larger or smaller than 0 if we are not able to form matrix\n        if(upper != 0 || lower != 0) {\n            return empty;\n        }\n        \n        return result;\n    }\n};\n```
['C']