Easy to understand.  Simple Greedy approach. Beats 80% of the solutions in TC.
Intuition\nGreedy as filling of matrix mostly gets solved with it.\n\n# Approach\n1) As there are two rows only and digit could be 0 and 1 only so max column su
# Intuition\nGreedy as filling of matrix mostly gets solved with it.\n\n# Approach\n1) As there are two rows only and digit could be 0 and 1 only so max column sum can be 2 so assign 1 each to both blocks of that column\nand subtract upper and lower by 1.\n2) And if column sum is 1 then by greedy select if upper or lower is not yet 0 then assign accordingly and subtract;\n3) During the loop if any of the conditions not satisfy then return {}.\n4) Final check if upper or lower is not zero then also return {}.\n5) Otherwise return the ans 2D ans matrix;\n\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n        int m = colsum.size();\n        vector<vector<int>> ans(2, vector<int>(m, 0));\n        \n        for (int j = 0; j < m; ++j) {\n            if (colsum[j] == 2) {\n                // If colsum[j] is 2, both rows must have a 1 in this column\n                if (upper > 0 && lower > 0) {\n                    ans[0][j] = 1;\n                    ans[1][j] = 1;\n                    upper--;\n                    lower--;\n                } else {\n                    return {}; \n                }\n            }\n        }\n        \n        for (int j = 0; j < m; ++j) {\n            if (colsum[j] == 1) {\n                // If colsum[j] is 1, we need to decide which row to place the 1 in\n                if (upper > 0) {\n                    ans[0][j] = 1;\n                    upper--;\n                } else if (lower > 0) {\n                    ans[1][j] = 1;\n                    lower--;\n                } else {\n                    return {}; // Not enough upper or lower sum to satisfy colsum[j]\n                }\n            }\n        }\n        \n        // After filling, both upper and lower sums should be zero\n        if (upper != 0 || lower != 0) {\n            return {};\n        }\n\n        return ans;\n    }\n};\n\n```
['Array', 'Greedy', 'Matrix', 'C++']