🔥C++ greedy Solution O(N)
\tIntuition- I am checking greedily that First I am checking for colsum value 2\n\t if at any given point of time I do not have enough lower and upper  to make 
**\tIntuition- I am checking greedily that First I am checking for colsum value 2\n\t if at any given point of time I do not have enough lower and upper  to make sum 2\n\t i will return false , otherwise will check for 0 and 1 in next loop.**\n\t \n\t\tclass Solution {\n\t\tpublic:\n\t\t\tvector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n\t\t\t\t\t  vector<vector<int>> ans(2,vector<int>(colsum.size(),0));\n\t\t\t\t\t  bool flag=true;\n\t\t\t\t\tfor(int i=0;i<colsum.size();i++){\n\t\t\t\t\t\tif(colsum[i]==2){\n\t\t\t\t\t\t\tif(lower<=0 || upper<=0){\n\t\t\t\t\t\t\t\tflag=false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tans[0][i]=ans[1][i]=1;\n\t\t\t\t\t\t\tupper--;\n\t\t\t\t\t\t\tlower--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tif(!flag) return {};\n\t\t\t\t\t for(int i=0;i<colsum.size();i++){\n\t\t\t\t\t\t if(colsum[i]==2) continue;\n\t\t\t\t\t\t else if(colsum[i]==0) ans[0][i]=ans[1][i]=0;\n\t\t\t\t\t\t else{\n\t\t\t\t\t\t\t if(lower>0){\n\t\t\t\t\t\t\t\t ans[1][i]=1;\n\t\t\t\t\t\t\t\t ans[0][i]=0;\n\t\t\t\t\t\t\t\t lower--;\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t else if(upper>0){\n\t\t\t\t\t\t\t\t ans[0][i]=1;\n\t\t\t\t\t\t\t\t ans[1][i]=0;\n\t\t\t\t\t\t\t\t upper--;\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t else {\n\t\t\t\t\t\t\t\t flag=false;\n\t\t\t\t\t\t\t\t break;\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t }\n\t\t\t\t\t }\n\t\t\t\tif(!flag || lower>0 || upper>0) return {};\n\t\t\t\treturn ans;\n\t\t\t} \n\t\t};
['Greedy', 'C']