C++ || O(n) || Greedy || Easy To Understand ✔
here colsum[i] = 0 or 1 or 2\nfor colsum[i] == 0 => both upper and lower row has value 0\nfor colsum[i] == 2 => both upper and lower row has value 1\nfor colsum
here `colsum[i] = 0 or 1 or 2`\nfor `colsum[i] == 0 => both upper and lower row has value 0`\nfor `colsum[i] == 2 => both upper and lower row has value 1`\nfor `colsum[i] == 1 => if upper > lower then upper row value = 1 else lower row value = 1`\n\n```\nclass Solution {\npublic:\n\tvector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n\t\tint n = colsum.size();\n\t\tvector<vector<int>> ans(2, vector<int>(n, 0));\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (colsum[i] == 2)\n\t\t\t{\n\t\t\t\tans[0][i] = 1;\n\t\t\t\tans[1][i] = 1;\n\t\t\t\tupper--;\n\t\t\t\tlower--;\n\t\t\t}\n\t\t\telse if (colsum[i] == 1)\n\t\t\t{\n\t\t\t\tif (upper > lower)\n\t\t\t\t{\n\t\t\t\t\tans[0][i] = 1;\n\t\t\t\t\tupper--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tans[1][i] = 1;\n\t\t\t\t\tlower--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lower == 0 && upper == 0)\n\t\t{\n\t\t\treturn ans;\n\t\t}\n\t\treturn {};\n\t}\n};\n```\n\n**If find Helpful *Upvote It* \uD83D\uDC4D**
['Greedy', 'C', 'C++']